品易云推流 关闭
文章详情页
文章 > MongoDB > mongodb查询不为空怎么写?

mongodb查询不为空怎么写?

MongoDB

头像

yang

2020-06-02 11:41:475676浏览 · 0收藏 · 0评论

mongodb中查询不为null并且存在记录的语句如下:

db.test.find({"test":{"$ne":null}});
db.test.find({"test":{"$ne":null, $exists:true}});

mongodb中查询存在且不为null,不为""(空字符串)

List testList = new ArrayList<>();
 
testList .add(null);
 
testList .add("");
 
queryUser.put("test", new BasicDBObject("$nin", testList));

更多mongodb相关文章请关注python自学网

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图