If I have a document with two values:
{
"name" : "Bob",
"location" "France"
}
And then pass an array to the document that contains “name”, “country”. How do I ensure that the entire document is updated, with “location” removed?
I will not be aware of the differences between the two documents, so I wont be able to unset a specific field. I am looking for a method to simply replace the document data with the array supplied.
If you supply
updatewith a new document containing the records you want, you will replace the document.For example:
Of course, if you had the
_idof the document, this would be a better way of specifying the update (rather than passing back the document you just inserted like above)