我在 MongoDb 上从 GoLang 触发 mgo 以查找修剪字符串长度大于零的记录,我在下面尝试过,但都不起作用,请帮忙。
findQuery["shopname"] = bson.M{"$where": "len > 0"}
findQuery["shopname"] = bson.M{"$where": "shopname.len > 0"}
findQuery["shopname"] = bson.M{"$where": "this.shopname.len > 0"}
findQuery["shopname"] = bson.M{"$regex": ".*.*"}
如果您只是在寻找非空值,请尝试以下操作:
bson.M{"$exists": true, "$ne": ""}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句