📜  firebase firestore async await 事务 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:01.197000             🧑  作者: Mango

代码示例1
var docRef = admin.firestore().collection("docs").doc(docId);
let doc = await admin.firestore().runTransaction(t => t.get(docRef));

if (!doc.exists) {throw ("doc not found");}
var newLikes = doc.data().likes + 1;

await doc.ref.update({ likes: newLikes });