Reputation: 3550
Is there any way to determine the date created for dynamically created mongo databases and collections?
Upvotes: 0
Views: 831
Reputation: 3356
For database: You can check the creation time for "database-name.ns" file
ls -l test.ns
-rw------- 1 root root 16777216 Jun 12 07:10 test.ns
For collection: Most of time collection is created when you insert something into it. So, if you are not creating the collection using createCollection() command and you are using the default ObjectId for _id key, then you can get a rough estimate of the creation of the collection by knowing the time at which the first document inserted in that collection.
Mongo > db.test.find().sort({$natural : 1}).limit(1).toArray()[0]._id.getTimestamp()
ISODate("2013-06-12T01:40:04Z")
Upvotes: 1