Hi! I would like to lock a batch of documents for processing in an application consisting of multiple instances. While one instance has selected a batch of documents for further processing, other instances should not be able to select it.
findAndModify appears to be a perfect solution, but it only chooses a single document from the query, then updates it and returns the original version.
What I need, is a similar method for a batch of documents. It should in particular:
- Update or lock a batch of documents in a single operation,
- Allow to set a limit to the batch size,
- Return the batch for further processing.
Is there any way to accomplish this challenge?