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 查询表中是否含有某个字段
上一篇:mysql数据库增删改查


下一篇:cssDay10