{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "A", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "A", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "B", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "C", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "C", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "C", "id" : "xxx001"}
{ "_id" : ObjectId("5a5ec3cd50a8xxxxxxdb82"), "date" : "2018-01-17 11:32:29", "type" : "A", "id" : "xxx002"}
根据id和type去查询,其中type可能多个也可能没有,只用id查询:
比如:
id=xxx001的所有记录-这个好弄
id=xxx001且type=A的所有记录-这个也好弄
id=xxx001且type=A和B的所有记录-这个怎么实现
id=xxx001且type=C和B的所有记录-这个怎么实现
现在用下面的方式,但是type是多个条件就不管用了,只能一个
data.put("id", "xxx001");
data.put("type", "A"); //这里只能填一个,不好多个
basicDBObject = new BasicDBObject(data);
FindIterable iter = document.find(basicDBObject);
求解各位大神,java实现
谢谢