zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

mongodb查询不为空怎么写?

2023-04-18 14:24:02 时间

mongodb查询不为空怎么写?

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自学网