Created
March 11, 2013 16:44
-
-
Save jgatjens/5135580 to your computer and use it in GitHub Desktop.
Mongodb - script collection multiples query
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 conn = new Mongo(); | |
var db = conn.getDB("test"); | |
var myCursor = db.images.find(); | |
myCursor.forEach( | |
function(myDoc) { | |
// print( "images: " + tojson(myDoc) ); | |
var myAlbum = db.albums.findOne( { "images": myDoc._id } ); | |
// print(myAlbum); | |
if (myAlbum == null) { | |
print('images removed _id: ' + myDoc._id ); | |
db.images.remove(myDoc); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment