Currently, I am dealing with the following scenario:
An API request from one service is creating multiple MongoDB documents in a single collection. For example:
[
{_id: 1, test1: 2, test: 3},
{_id: 2, test1: 3, test: 4}
]
Subsequently, a second service reads these documents and retrieves additional information. As a result, I am constructing an object like:
[
{_id: 1, newValue: 4},
{_id: 2, newValue: 4}
]
Now comes my question: Is it possible to update all the documents at once using the "_id" value? The challenge is that I want to avoid updating each document individually due to their large number. Therefore, I am considering deleting all the existing documents and inserting them again with all the necessary information. What are your thoughts on this approach?