Reputation: 20726
Would be nice if someone knows some examples for my "Query".
If have an Collection with Prices and Timestamps, i have to query for the records withe the newest timestamp "only".
I could query for all records sorted by timestamp and do an second query with the newest timestamp from the result, but i suppose this is not the best way (500.000 records). Does someone knows an good way to do this with mongoDB and PHP5?
Upvotes: 0
Views: 81
Reputation: 35149
If you are using a standard, auto-generated default '_id' primary field, that is timestamp based. Getting a single (limit(1)
) in descending order will be the most recent document.
Beyond that, depends on the schema you are using.
Upvotes: 2