Transaction

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 }

async load(arg, opts) → Document or undefined

Loads a document in transaction.

  • argDocument or DocumentReference
  • opts → load options.

See Document and DocumentReference load() for options

async save(doc, opts) → Document

Saves Document in transaction.

async delete(arg)

Deletes document in transaction.

  • argDocument 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);
});