【发布时间】:2021-11-14 05:40:01
【问题描述】:
这个问题有点类似于Firebase transaction returns null and completes without error。不过,我已经有了建议的解决方案。
以下使用 Firebase web 版本 9。在节点 v14.17.3 中运行
const returnVal = await runTransaction(firebaseRef, async node => {
console.log("1", node);
if (node && node.ready != true) {
node.ready = true;
}
console.log("2", node);
return node;
});
if (!returnVal.committed) throw new Error("Not committed");
console.log("3", returnVal.snapshot.toJSON());
在你继续说之前,我没有将节点设置为空对象,我希望它稍后会成为一个对象。
这是我的输出。
1 null
2 null
1 {otherMeta: {…}}
2 {otherMeta: {…}, ready: true}
3 null
如您所见,交易以空值完成。这很奇怪。
【问题讨论】:
标签: javascript node.js firebase-realtime-database transactions