Skip to content
Buy me a coffee

createBatcher

createBatcher<I, R>(options): Batcher<I, R>

Defined in: src/batcher.ts:43

DataLoader / bottleneck-Batcher style batching:

const users = createBatcher({ maxSize: 100, maxWait: '5ms', key: (id) => id, run: (ids, { signal }) => db.usersByIds(ids, { signal }) });
const [a, b] = await Promise.all([users.load('1'), users.load('2')]); // one query

I

R

BatcherOptions<I, R>

Batcher<I, R>