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.

3
  • 1
    I believe this might be a duplicate: stackoverflow.com/questions/8749971/… Commented Jan 21, 2013 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, Commented Jan 22, 2013 at 1:59
  • To find all objects created after 2013-01-21, this would be the query... db.User.find({'_id': {'$gte' : ObjectId('50FCCB500000000000000000')}}) Commented Jan 22, 2013 at 2:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.