As compare to shell, querying in java is quite different. However I
would like to share how I have done it, and also suggests to post it
under java-driver wiki page
public List<BasicDBObject> query(String query) {
BasicDBObject queryObject = new BasicDBObject();
BasicDBObject predicate = new BasicDBObject("$lte",new Date()); //
could be greater than
queryObject.put("dob", predicate);
DBCursor cur = myCollection.find(queryObject);
List<DBObject> resultCollection = new ArrayList<DBObject>();
try {
while (cur.hasNext()) {
DBObject s = new DBObject(cur.next().toString());
resultCollection.add(s);
}
} catch (Exception e) {
//do something on errors
e.printStackTrace();
}
logger.debug(resultCollection);
return Collections.unmodifiableList(resultCollection);
}
On the command line
db.mycollection.find({ "dob" : { "$lte" :
ISODate("2011-01-11T18:42:00Z") }});
Cheers,
Samantha
On Jul 6, 5:40 pm, Scott Hernandez <
scotthernan...@gmail.com> wrote:
> I'm not sure what the question is. Yes, you can do this in java.
>
>
http://groups.google.com/group/mongodb-user/browse_thread/thread/175b...