Time based queries on _id

17 views
Skip to first unread message

Fredrik Björk

unread,
Jul 3, 2012, 3:25:03 PM7/3/12
to mongod...@googlegroups.com
Is it possible to do time based queries on _id? i.e give me all documents that were created less than 24 hours ago?

Scott Hernandez

unread,
Jul 3, 2012, 3:31:21 PM7/3/12
to mongod...@googlegroups.com
Yes, you can do a range query with an ObjectId with a time from yesterday for example. Depending on the language there may be a helper method to construct a fake ObjectId based on a Date/Timestamp. Take a look at your API docs for your ObjectId implementation.

On Tue, Jul 3, 2012 at 8:25 PM, Fredrik Björk <fredri...@gmail.com> wrote:
Is it possible to do time based queries on _id? i.e give me all documents that were created less than 24 hours ago?

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Reply all
Reply to author
Forward
0 new messages