Created
November 27, 2019 05:42
-
-
Save izmailoff/386d4d606632208a91d62cda4cae451f to your computer and use it in GitHub Desktop.
Mongo shell script to get latest docs in each collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cols = db.getCollectionNames(); | |
cols.forEach(x => { | |
var res = db[x].find({}).sort({_id: -1}).limit(3); | |
print(x + ": "); | |
res.forEach(x => print(x._id + " is " + x._id.getTimestamp())); | |
print(); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prints: