Reputation: 23675
Is there an easy way of getting the datetime of the last change to a collection (including changes to any of its documents or children, whether that change be updating, inserting, deleting, etc...) without having to log a datetime manually? If there isn't an automatic way of doing this, what's a good way of manually logging those changes so they're accesible by an application?
Upvotes: 0
Views: 104
Reputation: 17208
Probably higher up in the stack, like at the application server level.
If you can get by with the last modification time across all collections, maybe you can use the oplog.
If you must store it in the database, you could perform a separate, log-like insert to a separate, capped collections, and let the server generate the object ID if you like. Then you can fetch the latest object ID and derive the time from that. (If you need better than one-second precision, you'll need to generate the timestamp on the client or use a different approach to generate it on the server.)
Upvotes: 0
Reputation: 1034
There is a feature request in Jira for this. Take a look and vote:
https://jira.mongodb.org/browse/SERVER-1891
Upvotes: 2