Collection Query4Db. Tablename.find ({"ListData.listData1.field":2});5 Non-collection queries6Db. Tablename.find ({"Field":2});7 Multi-Criteria Query8Db. Tablename.find ({"Field1":1, "Field2": "Test"});9 Ten Non-collection new OneDb. TableName.Update({},{$Set: {"New_field":1}}, {multi:true}) ADb. TableName.Update({"New_field": {$exists: false}},{$Set: {"New_field": Numberint ("0")}},{multi:true}) - - the Collection New -Db. Vac_order.find ({}). ForEach (function(Order){ - Order. Orderdetail.foreach (function(detail) { -Detail. Mappingdetail.foreach (function(mapping) { + if(!mapping.newfield) { -Mapping.newfield=0 //new Field + } A }) at }) -Db. Vac_order.Save(Order) - }) - - Non-collection Delete -Db. TableName.Update({}, {$unset: {"New_field":1}},{multi:true}) in Collection Delete -Db. Vac_order.find ({}). ForEach (function(Order){ to Order. Orderdetail.foreach (function(detail) { +Detail. Mappingdetail.foreach (function(mapping) { - if(Mapping.newfield) { the DeleteMapping.newfield//Delete a field * } $ })Panax Notoginseng }) -Db. Vac_order.Save(Order) the }) + A the Non-collection modifications +Db. TableName.Update({"Field": "Condition"},{$Set: {"field": "New Value"}},{multi:true}) - $ Collection Modification $Db. Vac_order.find ({}). ForEach (function(Order){ - Order. Orderdetail.foreach (function(detail) { -Detail. Mappingdetail.foreach (function(mapping) { the if(Mapping.newfield) { -Mapping.newfield=1//re-assign valueWuyi } the }) - }) WuDb. Vac_order.Save(Order) -})
MongoDB script Execution Add, delete, change, check