0

I am trying to update an attribute of a field.

For example, updating the name "Orchid garden" to a new name, let's say, "The Beautiful Garden"...

I am following the syntax given in the MongoDB Documentation but it seems that I am missing something.

(The database is called plants.)

The field information is written in JSON, click here to preview

Here is what I was trying:

db.gardens.update( {name: "Orchid Garden"}, {$set: {name : "Gothenburg Orchid Garden"}}  )
Devesh
  • 4,500
  • 1
  • 17
  • 28

1 Answers1

1

You have a nested garden object so you have to use the dot notation

db.gardens.update( {"garden.name": "Orchid Garden"}, {$set: {"garden.name" : "Gothenburg Orchid Garden"}} )
mickl
  • 48,568
  • 9
  • 60
  • 89