Lock on sub-document in mongo

Hello,
For locking on document level we do have findAndModify which locks the document even if parallel calls are received and only releases the lock until the data is updated so that the next task in queue will read only the updated document.
But is there anything for locking a sub-document or specific key in a document?
For my question let’s take an example of mongo data for a single document:


{
	"reservedQuantity": 100,
	"sku": "ABCD",
	"inStock": 200,
	"shipReserved": 400
}

Let’s say there is a high traffic with parallel calls to update reservedQuantity for sku ABCD . Is there any function which enables to lock only the key reservedQuantity until it is updated and meanwhile allows other calls to update data in parallel and consume locks for other keys in the same document?

1 Like

Please vote … :point_down: