Last active
February 28, 2016 21:51
-
-
Save oldaccountarchived/a9a28f191ed1d7d42ef9 to your computer and use it in GitHub Desktop.
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
db.getCollection('posts') | |
.find({}) | |
.forEach(function(myDoc) { | |
myDoc.categories.forEach(function(category) { | |
var cursor = db.getCollection('postcategories') | |
.find({"_id":category}); | |
if (!cursor.hasNext()) { | |
printjsononeline(category); | |
var cursor2 = db.getCollection('posts').find({categories: { $in: [category] }}) | |
while ( cursor2.hasNext() ) { | |
print( cursor2.next() ); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment