Created
September 25, 2014 06:30
-
-
Save pvoznenko/c4ba37e2cc7e0e60bc4a to your computer and use it in GitHub Desktop.
f7
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
db.albums.ensureIndex( {"images" : 1} ); | |
db.albums.aggregate( | |
{ $unwind : "$images" }, | |
{$group: { _id:null, images: {$addToSet:"$images"}}} | |
).forEach(function(doc){ | |
db.images.remove({_id: {$nin: doc.images}}); | |
// var kittens = db.images.find({tags: "kittens", _id: {$in: doc.images}}); | |
// print(kittens.count()); | |
}); | |
db.images.find({tags: "kittens"}).count(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment