Created
July 16, 2014 14:51
-
-
Save moonhouse/2dbad54004c7d724e981 to your computer and use it in GitHub Desktop.
List objects with a certain id in MongoDB regardless of collection
This file contains hidden or 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 searchId = function (objId) { | |
| coll = db.getCollectionNames(); | |
| coll.forEach(function(collName) { | |
| obj = db[collName].findOne({'_id': ObjectId(objId)}); | |
| if (obj !== null) { | |
| print(collName + " " + objId); | |
| } | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment