Skip to content

Replacement for Firestore.WriteBatch that makes it easy without worrying about 500 limit per batch written in typescript.

Notifications You must be signed in to change notification settings

toniremi/firestore-multibatch-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

firestore-multibatch-typescript

Replacement for Firestore.WriteBatch that makes it easy without worrying about 500 batch operations limit written in typescript.

With this replacement you do not have to worry about the max limit of 500 writes per batch. Just add batches and call batch.commit() when you are finished.

This is an adaptation from https://github.com/stpch/firestore-multibatch library to TypeScript.

Installation

Simply drag this file anywhere inside your src folder and call it from your file.

Usage

import * as admin from 'firebase-admin'
// import multiBatch
import { MultiBatch } from "./multiBatch";

admin.initializeApp({/* ... */});

const db = admin.firestore();
const batch = new MultiBatch(db); // Instead of db.batch()

// Perform batch operations same as with db.batch()
for (let i = 0; i < 1000; i++) {
    batch.set(db.collection('test').doc(), {foo: 'bar'});
}

// with async/await but can also be used with simple promise.then()
const result = await batch.commit();

About

Replacement for Firestore.WriteBatch that makes it easy without worrying about 500 limit per batch written in typescript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published