Skip to content

Instantly share code, notes, and snippets.

@directionless
Last active December 14, 2015 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save directionless/5057589 to your computer and use it in GitHub Desktop.
Save directionless/5057589 to your computer and use it in GitHub Desktop.
mongodb sub document trouble
db.foo.insert( {_id: 1}, { "$set": {param: "one" }} )
db.foo.update(
{
"_id": 1,
"sub._id": 2
},
{ $set: { "sub.$": {
"param": 2,
"place": "Boston"
} } },
{"upsert":true}
)
// returns: E11000 duplicate key error index: test.foo.$_id_ dup key: { : 1.0 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment