MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Come utilizzare l'operatore $in in mongodb con due campi in java

Prova questo

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);
    }