title: How to store Incremental Data in MongoDB?
body: <p>I have millions of documents in various collection. </p>
  
  <p>My application has to periodically update some incremental data to MongoDB. How do I acheive this?</p>
  
  <p>For every record in incremental data, if the record exists it must be updated with new values otherwise it has to be inserted. </p>
  
  <pre><code>{
     _id: 'some ID',
     lifnr: 12345,
     bukrs: 3455,
     amount: 500
  },
  {
     _id: 'some ID',
     lifnr: 12346,
     bukrs: 3456,
     amount: 5200
  }
  </code></pre>
  
  <p>Assuming above is my data, with lifnr and bukrs as compound index with unique constraint. Any new records with {lifnr &amp; bukrs} value same as any of existing should replace the old amount. If it is a new record of unique {lifnr &amp; bukrs}, then it must insert/append it. </p>
  
  <p>Guide me to the approach. Thanks </p>