Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DB db = mongo.getDB("yourDbName");
- DBCollection coll = db.getCollection("person");
- DBObject query = new BasicDBObject();
- query.put("dateCreated", new BasicDBObject($exists : true));
- DBCursor cur = coll.find(query).sort(new BasicDBObject("dateCreated", 1)).limit(10);
- while(cur.hasNext()) {
- DBObject obj = cur.next();
- // Get data from the result object here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement