我在React App中使用Firestore,只要有两个并行请求,我就会看到此错误。
这个错误究竟意味着什么?
Firestore (4.5.0) 2017-11-05T16:39:32.783Z: RPC "commit" failed with
status: 400 response text: {
"error": {
"code": 400,
"message": "the stored version (1509899972098969) does not match
the required base version (1509899938109577)",
"status": "FAILED_PRECONDITION"
这是我的代码。这是一个类似的系统。
await getUserVotesRef().set({ userVotes }, { merge: true });
await fs.runTransaction(t =>
t.get(coinVoteRef).then(doc => {
// Add one person to the city population
let coinIdCount = (doc.exists && doc.data()[coinId]) || 0;
coinIdCount = !currVote ? coinIdCount + 1 : coinIdCount - 1;
coinIdCount = coinIdCount >= 0 ? coinIdCount : 0;
t.set(coinVoteRef, { [coinId]: coinIdCount }, { merge: true });
})
);