Let's say I'm storing a collection of ids in a document as shown as below.
{
"id": "an id",
"post_ids": [
"post_id 1",
"post_id 2",
"post_id 3",
"post_id 4",
]
}
when I add a new value into the "post_ids" array, what's the best practice?
- Should I lock the document? Since this is very simple operation, my guess is that it would be fast enough not to interfere other requests.
- Do not lock it, but check if the original document has been modified before updating the document?