MongoDB shell command common

Add new field to every document in a MongoDB collection

db.your_collection.update({},
                          {$set : {"new_field":1}},
                          {upsert:false,
                          multi:true}) 

Remove field from every document in a MongoDB collection

db.your_collection.update({},
                          {$unset : {"old_field":null}},
                          {upsert:false,
                          multi:true}) 

Remove field from every nested document in a MongoDB collection

db.your_collection.update({},
                          {$unset : {"old_field.$[].old_field_child":null}},
                          {upsert:false,
                          multi:true}) 

Rename field from every document in a MongoDB collection

db.your_collection.update({},
                          {$rename: {"old_field_name":"new_field_name"}},
                          {upsert:false,
                          multi:true}) 

Backup and Restore

mongodump -d CollectionName-o c:\data\mongodb\backup
mongorestore c:\data\mongodb\backup