2

How do I write a mongodb shell query that will return the documents (or just document ids) for all objects created after a specific date? I see examples like the following...

return query based on date

But they just return the timestamp, I want to query based on a timestamp. I don't think the logic is as easy as looking for objects higher than a specific objectid, because if mongodb is sharded, then there are multiple servers creating objects.

Community
  • 1
  • 1
Craig
  • 53
  • 1
  • 5
  • 1
    I believe this might be a duplicate: http://stackoverflow.com/questions/8749971/can-i-query-mongodb-objectid-by-date – Sammaye Jan 21 '13 at 22:34
  • Yes, you are right. It makes sense now, I take the hex value of the epoch time, and add "0000000000000000", that will give me the base objectid to start at. Thanks, – Craig Jan 22 '13 at 01:59
  • To find all objects created after 2013-01-21, this would be the query... db.User.find({'_id': {'$gte' : ObjectId('50FCCB500000000000000000')}}) – Craig Jan 22 '13 at 02:04

0 Answers0