I'm using MongoDB with PHP and I want to update all fields in a document if it matches certain criteria.
Each document has a title - if the title matches I want to update all the fields within that document with the values of the new document.
Here's some pseudocode:
if doc.title == newdoc.title
replace doc with newdoc
else
insert newdoc
How would I go about this in MongoDB?