Mongodb - Updating Only $ref From Dbref Field Type
I need to update a field of multiple collection documents. The field is a DBRef and I just need to change the $ref field value. One of the documents is like this: { '_id' : { '$oi
Solution 1:
You can use dot notation in order to update the nested document. Note that, whenever the dot notation is used, it should be put between quotes.
db.collection.update(
{},
{ $set:{
"codeId.$ref":"code"
}
},
false,
true
);
You can read more about Database References.
Post a Comment for "Mongodb - Updating Only $ref From Dbref Field Type"