2

I have a collection in MongoDB that contains a list of objects. Each object has an array of "updaters" which are objects with a field that I want to update. One of the updaters in that array needs a description updated. How can i update just the descrption of the the updater object, that I know "updaterId" of.

enter image description here

Update:

It appears to me that setting the flag multi: true will do the trick in Mongo 2.2+.

db.configurations.update(
  {"updaters.updaterId": "90391154-67BB-452E-A1A7-A07A98B94F86"},
  {$set: {"updaters.$.description": "This tool will prevent users from Unloading Linked Revit files for \"all users\" which causes such Linked File to be unloaded by default when opening project."}},
  {multi: true}
)
konrad
  • 3,544
  • 4
  • 36
  • 75

1 Answers1

2

You can update the description updaterId like this:

db.collection.update( {"updaters.updaterId" : updaterId } ,
               {$set : {"updaters.$.description" : "My description"}} ,
               false ,
               true);

enter image description here

Pankaj Jatav
  • 2,158
  • 2
  • 14
  • 22