Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


       
        assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
       
        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection("otherCollection");
       
        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
        assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);
       
        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
       
View Full Code Here


        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
        assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
        assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
View Full Code Here

        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field a", key1.containsField("a") && "1".equals(key1.getString("a")));
        assertTrue("No index on the field b", key2.containsField("b") && "-1".equals(key2.getString("b")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionAndIndex");
        assertNotNull("No record with 'testInsertDynamicityEnabledCollectionAndIndex' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
View Full Code Here

        BasicDBObject key1 = (BasicDBObject) indexInfos.get(1).get("key");

        assertFalse("No index on the field a", key1.containsField("a") && "-1".equals(key1.getString("a")));

        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
        assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id", b);

        b = testCollection.findOne("testInsertDynamicityEnabledCollectionOnlyAndURIIndex");
        assertNull("There is a record with 'testInsertDynamicityEnabledCollectionOnlyAndURIIndex' _id in the test collection", b);
View Full Code Here

        BasicDBObject key2 = (BasicDBObject) indexInfos.get(2).get("key");

        assertTrue("No index on the field b", key1.containsField("b") && "-1".equals(key1.getString("b")));
        assertTrue("No index on the field a", key2.containsField("a") && "1".equals(key2.getString("a")));

        DBObject b = collection.findOne("testInsertAutoCreateCollectionAndURIIndex");
        assertNotNull("No record with 'testInsertAutoCreateCollectionAndURIIndex' _id", b);

        b = testCollection.findOne("testInsertAutoCreateCollectionAndURIIndex");
        assertNull("There is a record with 'testInsertAutoCreateCollectionAndURIIndex' _id in the test collection", b);
View Full Code Here

          System.out.println(s);
      }
     
      DBCollection coll = db.getCollection("testData");
     
      DBObject myDoc = coll.findOne();
      System.out.println(myDoc);
     
      DBCursor cursor = coll.find();
      try {
         while(cursor.hasNext()) {
View Full Code Here

    DBCollection collection = getCollection( key.getEntityKey() );
    DBObject searchObject = prepareIdObject( key.getEntityKey() );
    DBObject projection = getProjection( key, true );

    return collection.findOne( searchObject, projection, readPreference );
  }

  private DBObject getObject(EntityKey key, TupleContext tupleContext) {
    ReadPreference readPreference = getReadPreference( tupleContext );
View Full Code Here

    DBCollection collection = getCollection( key );
    DBObject searchObject = prepareIdObject( key );
    BasicDBObject projection = getProjection( tupleContext );

    return collection.findOne( searchObject, projection, readPreference );
  }

  private BasicDBObject getProjection(TupleContext tupleContext) {
    return getProjection( tupleContext.getSelectableColumns() );
  }
View Full Code Here

            QueryBuilder filterBuilder = QueryBuilder.start(NodeMongo.KEY_REVISION_ID).is(1);
            filterBuilder.and(NodeMongo.KEY_CHILDREN).is(1);
            filter = filterBuilder.get();
        }

        NodeMongo nodeMongo = (NodeMongo) nodeCollection.findOne(query, filter);

        return nodeMongo;
    }

    private boolean revisionIdExists() {
View Full Code Here

    }

    @Override
    public HeadMongo execute() throws Exception {
        DBCollection headCollection = mongoConnection.getHeadCollection();
        HeadMongo headMongo = (HeadMongo) headCollection.findOne();

        return headMongo;
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.