Performs multiple document operations in transaction.
let result = await store.transaction(async tx => {
let doc = await tx.load(store.doc('messages/first'));
doc.data.count++;
await tx.save(doc);
return { ok: true };
});
result // → { ok: true }
→ Document or undefined
Loads a document in transaction.
arg
→ Document
or DocumentReference
opts
→ load options.See Document and DocumentReference load()
for options
→ Document
Saves Document in transaction.
Deletes document in transaction.
arg
→ Document
or DocumentReference
let ref = store.doc('messages/first');
let doc = ref.existing();
await store.transaction(async tx => {
await tx.delete(ref);
await tx.delete(doc);
});