Skip to content

Instantly share code, notes, and snippets.

View trishagee's full-sized avatar

Trisha Gee trishagee

View GitHub Profile
DBObject jo = cursor.one();
(String)cursor.one().get("name");
DBCursor cursor = collection.find(new BasicDBObject("_id", "theId"));
(String) cursor.one().get("name")
DBCursor results = collection.find(new BasicDBObject("name", "The name I want to find"));
results.size();
for (DBObject result : results) {
// do something with each result
}
DBCursor results = collection.find(new BasicDBObject("name", "SomeName"),
new BasicDBObject("name", 1));
DBCursor results = collection.find(new BasicDBObject("name", "SomeName"),
new BasicDBObject("address", 0));
DBCursor results = collection.find(new BasicDBObject("numberOfOrders", new BasicDBObject("$gt", 10)));