0

I'd like to only get documents that were created in the last 24 hrs, is there a way to limit queries by age?

Can I use the doc ids? a limit query?

Should I add a date field and use min/max?

Some other way?

Thanks for any info!

boom
  • 10,856
  • 9
  • 43
  • 64
  • Adding a timestamp field with index would be the most straightforward and reliable solution. But if you're letting mongodb server generate object ids for you, then you can use _id field because it has a timestamp in it, and there's already an index. – Sergio Tulentsev Nov 04 '12 at 18:17
  • can you show me an example of the query? – boom Nov 04 '12 at 18:34
  • 1
    Here's an example of querying by date using the ObjectID: http://stackoverflow.com/questions/8749971/can-i-query-mongodb-objectid-by-date – Stennie Nov 04 '12 at 20:47

0 Answers0