如何检查mongodb中的字符串长度是否> 0?

时间:2018-04-05 20:42:12

标签: mongodb

我在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": ".*.*"}

2 个答案:

答案 0 :(得分:0)

如果您只是寻找非空值,请尝试以下方法:

UIScrollView

答案 1 :(得分:0)

另一种方法或另一种方法是检查数组的第0个元素是否存在。

fa fa-phone