I have the following schema:
unique_doc_id: {
title: title1,
desc: desc
listField: [listElement1, listElement2]
mapField: {someKey: someValue}
}
I have a microService1 which hosts an API used to take inputs for above document…then notifies microService2 using an unordered queue which is supposed to update this document in the DB.
I want to maintain field-level timestamps for concurrent updates on same field for the following scenario: Let’s say someone calls API at T1 with title1, at T2 (T1 + 1ms) with title2…but the updates reach microService2 out of order i.e. the T1 update reaches AFTER T2 update. i.e. let’s say the write of title2 happens first, so, when the title1 update reaches microService2, that write should fail. I beleive this can be done with field level timestamps.
Does mongoDB have support for adding version/timestamp at field level ??
Isn't this a common problem ?
Any doc links / example code chunks would help.
Thanks!