How to remove attribute from MongoDb Object? -


i have added middlename attribute customer object. customer simple object() instance. want remove attribute object. how can that? using mongodb interactive console.

you should use $unset modifier while updating:

// db.collection.update( criteria, objnew, upsert, multi ) --> reference

to delete:

db.collection.update(      {          "properties.service" : {               $exists : true           }      },      {           $unset : {               "properties.service" : 1           }      },      false,      true ); 

to verify have been deleted can use:

db.collection.find(      {          "properties.service" : {              $exists : true          }      }  ).count(true); 

remember use multi option true if want update multiple records. in case wanted delete properties.service attribute records on collection.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -