Answer the question
In order to leave comments, you need to log in
How to get the actual value from MongoDB when querying from multiple workers?
There is a function in the worker that makes a request to the database, and updates the value in it so that other workers do not select the same document in the database. But it turns out that the rest of the workers select the same document as the first worker. How can I make it so that each worker selects his own document that is not used by the previous one. An approximate picture of how everything is now being done is shown in the diagram. Please tell me the best way to do this.
Answer the question
In order to leave comments, you need to log in
await Model.findOneAndUpdate({ inUse: false }, { inUse: true });
Move work with monga into a separate service with api and control the competition in this service.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question