It's not possible to udpate a sub-document that does not exist like this.
Table.update({id: 'foo'}, {$set: {'foo.bar': 'baz'}}).exec();
It has to be done like this
Table.update({id: 'foo'}, {$set: {foo: {bar: 'baz'}}}).exec();
But this might override other properties inside the foo object.
{
"id": "foo",
"foo": {
"bar": "bar",
"baz": "baz"
}
}
Table.update({id: 'foo'}, {$set: {foo: {bar: 'baz'}}}).exec();
will result in
{
"id": "foo",
"foo": {
"bar": "baz"
}
}
It's not possible to udpate a sub-document that does not exist like this.
{ "id": "foo" }It has to be done like this
But this might override other properties inside the
fooobject.{ "id": "foo", "foo": { "bar": "bar", "baz": "baz" } }will result in
{ "id": "foo", "foo": { "bar": "baz" } }