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