title: How to replace items in MongoDB
body: <p>I request JSON objects with unique ids through an API. Some of these items already exist in my MongoDB database. Is there some functionality like this:</p>
  
  <pre><code>Collection.replace({ id: '12345' }, JSON_object)
  </code></pre>
  
  <p>which looks for an object with that id field in the first place, and then replaces it with the new object, if it finds one, or adds a new object to the collection, if no matching object was found?</p>
  
  <p>I am doing this in node.js with mongoose. Unfortunatly, the ObjectId implementation seems faulty there, so I am searching for a general approach.</p>