Can you execute parameterized queries using Java and MongoDB - sort of like prepared statements with JDBC?
What I would like to do is something like this. Configure a query that accepts a date range, and then call it with different ranges. I understand that DBCursor.find(...)
does not work this way - it is a kind of pseudo code to illustrate what I'm looking for.
DBCollection dbc = ... DBObject pQuery = (DBObject) JSON.parse("{'date' : {'$gte' : ?}, 'date' : {'$lte' : ?}}"); DBCursor aprilResults = dbc.find(pQuery, "2012-04-01", "2012-04-30"); DBCursor mayResults = dbc.find(pQuery, "2012-05-01", "2012-05-31"); ...
source share