Skip to content

Instantly share code, notes, and snippets.

@saihoooooooo
Last active January 22, 2016 05:41
Show Gist options
  • Save saihoooooooo/f6eb7661913636d0bb05 to your computer and use it in GitHub Desktop.
Save saihoooooooo/f6eb7661913636d0bb05 to your computer and use it in GitHub Desktop.
mongo update in document in array
db.rooms.insert({_id: 1234567890, members: [{name: "hoge", age: 20}, {name: "fuga", age: 21}]})
db.rooms.update({_id: 1234567890}, {$set: {"members.0.name": "piyo", "members.0.age": 18, "members.1.name": "rodorigesu", "members.1.age": 46}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment