如何在mongodb中使用$和operator - java驱动程序

时间:2014-06-09 13:57:47

标签: java mongodb

我们如何使用逻辑AND($和),

查询mongo

示例: 集合:主题

从收集主题我需要获得满足条件的所有记录,

totalmarks!= 10 and totalmarks!= 15。

2 个答案:

答案 0 :(得分:6)

在java驱动程序中等效。

List<DBObject> criteria = new ArrayList<DBObject>();
criteria.add(new BasicDBObject("totalmarks", new BasicDBObject("$ne", 10)));
criteria.add(new BasicDBObject("totalmarks", new BasicDBObject("$ne", 15)));
DBCursor dbCursor = collection.find(new BasicDBObject("$and", criteria));

答案 1 :(得分:0)

或者,对于较新的版本,可以将Bson对象用作过滤器。

If you have an issue with TextInput for make uppercase of all letter than you can use  
autoCapitalize = 'characters'and if you want to only first characters as a uppercase 
than you use autoCapitalize = 'words'.
But make sure you have not set **keyboard** type property.