Created
April 19, 2011 17:56
-
-
Save thesmith/929029 to your computer and use it in GitHub Desktop.
Delete sub items from container
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 lookup = 'http://pressassociation.com/brands/1166'; | |
var i=0; | |
var container = db.content.findOne({lookup: lookup}); | |
print('container currently has '+container.contents.length+' items.'); | |
for (i=0; i<container.contents.length; i++) { | |
if (container.contents[i] != null && container.contents[i].specialization == 'film') { | |
print('removing episode at poisition '+i+': '+container.contents[i]._id+' - '+container.contents[i].title); | |
//eval('db.content.update({_id: container._id}, {$unset: {"contents.'+i+'": 1 }})'); | |
} | |
} | |
db.content.update({_id: container._id}, {$pull : {"contents" : null }}); | |
var container = db.content.findOne({lookup: lookup}); | |
print('container now has '+container.contents.length+' items.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment