title: how to check if an document is updated or inserted in MongoDB
body: <p>I'm just wondering if there's way to check if a given document is updated or inserted in MongoDB after a upsert operation in Java:</p>
  
  <pre><code>DBCollection col = getCollection();
  // either this
  col.findAndModify(query, null, null, false, contact, false, true);
  // or this
  WriteResult wr = col.update(query, contact, true, false);
  </code></pre>