nutz及monggo版本1.r.61
代码如下
ZMoDoc cnd = ZMoDoc.NEW("$or",
Lang.list(ZMoDoc.NEW().all("adcode", contry),
ZMoDoc.NEW().all("adcode",
province)));
ZMoDoc keys = ZMoDoc.NEW();
keys.put("gid", 1);
keys.put("_id", 0);
DBCursor cursor = goodsLocDao().find(cnd, keys);
日志如下:
org.nutz.mongo.ZMoCo.find(ZMoCo.java:215) - db.goodsLoc.find({ "$or" : [ [ { "adcode" : { "$all" : [ "000000"]}} , { "adcode" : { "$all" : [ "210000"]}}] , [ { "adcode" : { "$all" : [ "000000"]}} , { "adcode" : { "$all" : [ "210000"]}}]]}, { "gid" : 1 , "_id" : 0})
[DEBUG] 2018-09-05 11:25:33.496 com.mongodb.diagnostics.logging.SLF4JLogger.debug(SLF4JLogger.java:56) - Sending command {find : BsonString{value='goodsLoc'}} to database xiaoi on connection [connectionId{localValue:2, serverValue:1690}] to server 192.168.0.168:27017
[WARN ] 2018-09-05 11:25:33.503 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/goods/test :
com.mongodb.MongoQueryException: Query failed with error code 2 and error message '$or/$and/$nor entries need to be full objects' on server 192.168.0.168:27017
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:521)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:510)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:431)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:404)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:510)