Skip to content

Instantly share code, notes, and snippets.

@asyndrige
Last active April 28, 2017 07:08
Show Gist options
  • Save asyndrige/4c6e2fbbab99a4e5d06b245afca132a9 to your computer and use it in GitHub Desktop.
Save asyndrige/4c6e2fbbab99a4e5d06b245afca132a9 to your computer and use it in GitHub Desktop.
var rights_id = db.getCollection('right').find({}, {_id:1}).map(function(item){ return item._id; })
db.getCollection('virtual_reading_room_group').update(
{},
{$push: {rights: {$each: rights_id}}}
);
//////////////////////////
db.getCollection('right').remove({"is_template": true});
var rights_id = db.getCollection('right').find({}, {_id:1, doc_type:1}).map(function(item){
return item._id;
});
var delete_rights_id = db.getCollection('right').find({"doc_type": "close"}, {_id:1, doc_type:1}).map(function(item){
return item._id;
});
db.getCollection('virtual_reading_room_group').update(
{},
{$pull: {rights: {$in: delete_rights_id}}}
);
db.getCollection('right').remove({_id: {$in: delete_rights_id}});
// db.getCollection('virtual_reading_room_group').update(
// {},
// {$push: {rights: {$each: rights_id}}}
// );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment