MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

Como usar o operador $in no mongodb com dois campos em java


Tente isso
BasicDBObject query = new BasicDBObject("names", new BasicDBObject("$in",      Arrays.asList("colombo")));
    query.append("age", new BasicDBObject("$gt", 20));
    FindIterable<Document> find = collection.find(query);
    MongoCursor<Document> iterator = find.iterator();
    Document doc = null;
    while (iterator.hasNext()) {
        doc = iterator.next();
        System.out.println(doc);
    }