Creates batch API with a set of functions (set,
upset, update, remove)
that are similar to regular set, update and remove with the only difference
that the batch counterparts do not return a promise and perform operations
only when commit function is called.
import { batch, collection } from'typesaurus'type Counter = { count: number }
const counters = collection<Counter>('counters')
const { set, update, remove, commit } = batch()
for (let count = 0; count < 500; count++) {
// Each batch can be up to 500 set, update and remove operationsset(counters, count.toString(), { count })
}
// Set 500 documents
commit().then(() =>console.log('Done!'))
Creates batch API with a set of functions (set, upset, update, remove) that are similar to regular set, update and remove with the only difference that the batch counterparts do not return a promise and perform operations only when commit function is called.
import { batch, collection } from 'typesaurus' type Counter = { count: number } const counters = collection<Counter>('counters') const { set, update, remove, commit } = batch() for (let count = 0; count < 500; count++) { // Each batch can be up to 500 set, update and remove operations set(counters, count.toString(), { count }) } // Set 500 documents commit().then(() => console.log('Done!'))