I have a list of records like
[
{"id":"1", "name":"a", "user":"u1"},
{"id":"2", "name":"b", "user":"u1"},
{"id":"3", "name":"c", "user":"u1"}
]
Now based on if an entry already exists or not in the database, it should either update or insert the document. Also for update there is a condition that the value of existing user
field should match the supplied value for user
in the document.
Of course I can run the list in a loop and use
mongoOperations.save(...);
But if I have a huge list then I will have to do one db operation per each entry which I don't think is efficient. Is there any other efficient way to perform this operation?