How to solve google cloud ndb data disappear when store at the same time?

47 Views Asked by At

In my app ,if two users answer the same question at the same time from two different browsers, the first answer was disappeared and the last answer was saved. How can I solve that problem?

User One ---> answer --> 23:44:44(time) ---> Question(A) ---> None ---> count (None)
User Two ---> answer --> 23:44:50(time) ---> Question(A) ---> ANSWER --->count(1)
I want to be
User One ---> answer --> 23:44:44(time) ---> Question(A) ---> ANSWER ---> count (1)
User Two ---> answer --> 23:44:50(time) ---> Question(A) ----> ANSWER---> count (2)

1

There are 1 best solutions below

2
Jim Morrison On

Unfortunately, it's unclear what you are attempting to accomplish here. Do you want to keep track of all answers, or reject the second answer?

Either way, it looks like you'll want to alter Question(A) entity in a transaction.