Project details
Firewalk is a lightweight library designed for effective traversal of Firestore collections in Node.js. It allows developers to process large sets of documents without overwhelming memory. With features like batch processing and concurrency control, Firewalk simplifies tasks from database migrations to data retrieval, ensuring smooth performance even with millions of records.
Firewalk is a lightweight, fast, and memory-efficient library designed for traversing Firestore collections in Node.js applications. It addresses the challenges posed by large document collections, enabling developers to efficiently access, modify, and manage data without overwhelming system memory.
Here’s a quick example demonstrating how to send emails to users from a Firestore collection using Firewalk:
import { firestore } from 'firebase-admin';
import { createTraverser } from 'firewalk';
const usersCollection = firestore().collection('users');
const traverser = createTraverser(usersCollection);
const { batchCount, docCount } = await traverser.traverse(async (batchDocs, batchIndex) => {
const batchSize = batchDocs.length;
await Promise.all(
batchDocs.map(async (doc) => {
const { email, firstName } = doc.data();
await sendEmail({ to: email, content: `Hello ${firstName}!` });
})
);
console.log(`Batch ${batchIndex} done! We emailed ${batchSize} users in this batch.`);
});
console.log(`Traversal done! We emailed ${docCount} users in ${batchCount} batches!`);
Firewalk features a simple interface with only two primary components:
For further exploration, the library's documentation provides comprehensive guidelines on setup, configuration, and advanced use cases such as concurrency adjustment and data field updates.
Firewalk is an essential tool for developers who work with large Firestore collections and require efficient data processing strategies. It streamlines complex tasks with practical solutions, making data management simple and effective.
Comments
0Start the conversation
Share the first comment.