java 调用 mongo (二)java中添加多个查询语句以及组合类型的查询
作者:互联网
BasicDBObject doc = new BasicDBObject(); doc.put("$exists",false); BasicDBObject docs = new BasicDBObject(); docs.put("catalog_id", catalogId); docs.put("isEsbSync_ml",doc); // Bson filter = Filters.eq("catalog_id", catalogId); FindIterable<Document> documents = collection.find(docs); // MongoCursor cursor = findIterable.iterator(); // while (cursor.hasNext()) { // System.out.println("----"+cursor.next()); // } // FindIterable findIterable = collection.find(filter); // MongoCursor cursor = findIterable.iterator(); // while (cursor.hasNext()) { // System.out.println("----"+cursor.next()); // } List<Document> list=new ArrayList<>(); if (documents!=null){ for (Document document : documents) { System.out.println("--document--"+document); list.add(document); } } System.out.println("----->>>"+list.size());
$exists 查询表中是否含有某个字段
标签:java,mongo,docs,System,查询,cursor,BasicDBObject,document,out 来源: https://www.cnblogs.com/1ming/p/15233941.html