Batch

Batch operation performs multiple writes in a single atomic operation.

let batch = store.batch();
batch.save(duck);
batch.save(feathers);
await batch.commit();
await store.batch(async batch => {
  batch.save(duck);
  batch.save(feathers);
});

TODO: See store.batch

save(doc, { type, merge }) → Document

Enqueues document save which is performed when batch is commited.

  • docDocument
  • typeset or update (defaults to set)
  • mergeBoolean (defaults to false), used only if type is set

TODO: see doc.save for options

delete(arg) → Document|DocumentReference

  • argDocument or DocumentReference

Enqueues document delete by providing a document or document reference.

let doc = store.doc('ducks/yellow');
await store.batch(async batch => {
  batch.delete(doc);
});
let doc = store.doc('ducks/yellow').existing();
await store.batch(async batch => {
  batch.delete(doc);
});

commit() → Promise

Commits a batch. Useful only if batch is created without callback.

let doc = store.doc('ducks/yellow').existing();
let batch = store.batch();
batch.delete(doc);
await batch.commit();