batch
batch
executes a series of operations in an atomic way - either all succeed or all fail.
await db.batch([
["set, {name: "Bob", age: 30}, "users", "bob"],
["update", {age: db.inc(3)}, "users", "alice"],
["delete", "users", "john"]
])
// equivalent firestore
let batch = fb.batch()
const ref_users = fb.collection("users")
const ref_bob = ref_users.doc("bob")
const ref_alice = ref_users.doc("alice")
const ref_john = ref_users.doc("john")
batch.set(ref_bob, {name: "Bob", age: 30})
batch.update(ref_alice, {age: db.inc(3)})
batch.delete(ref_john)
await batch.commit()