npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@db2lake/driver-firestore

v0.2.0

Published

Firestore source driver for db2lake

Downloads

30

Readme

@db2lake/driver-firestore

Firestore source driver for the @db2lake pipeline framework. Streams documents using Firestore queries with cursor-based pagination and snapshot-based batching.

Installation

Install the driver:

npm install @db2lake/driver-firestore

Credentials: provide credentials via appOptions.credential (e.g., credential.cert(...)) or use environment-based credentials where appropriate. Do not commit service account keys to source control.

Project structure

├── src/
│   ├── index.ts  # FirestoreSourceDriver implementation
│   └── index.test.ts  # unit tests
│   └── type.ts   # Type definitions for configuration
└── package.json  # Package metadata

Quick usage

import { FirestoreSourceDriver, FirestoreConfig } from '@db2lake/driver-firestore';
import { credential } from 'firebase-admin';

const config: FirestoreConfig = {
  appOptions: {
    credential: credential.cert(require('./service-account.json'))
  },
  collection: 'users',
  orderBy: [['lastName', 'asc']],
  limit: 50
};

const driver = new FirestoreSourceDriver(config);
try {
  for await (const batch of driver.fetch()) {
    console.log(`Processing ${batch.length} users...`);
  }
} finally {
  await driver.close();
}

Advanced example (filters, multiple sort fields)

import { FirestoreSourceDriver, FirestoreConfig } from '@db2lake/driver-firestore';
import { credential } from 'firebase-admin';

const config: FirestoreConfig = {
  appOptions: { credential: credential.cert(require('./service-account.json')) },
  collection: 'orders',
  where: [
    ['status', '==', 'pending'],
    ['amount', '>', 1000]
  ],
  orderBy: [ ['createdAt', 'desc'], ['amount', 'desc'] ],
  limit: 100,
  startAfter: [new Date('2025-01-01'), 5000]
};

const driver = new FirestoreSourceDriver(config);
try {
  for await (const batch of driver.fetch()) {
    for (const doc of batch) console.log(doc.id, doc);
  }
} finally {
  await driver.close();
}

Configuration reference

  • where?: [string, WhereFilterOp, any][] — filter conditions
  • orderBy?: [string, OrderByDirection][] — ordering (required when using cursors)
  • limit?: number — batch size (default 100)
  • startAt? | startAfter? | endBefore? | endAt? — cursor values matching orderBy
  • appOptions — options for initializeApp including credentials
  • appName? — optional Firebase app name
  • collection — collection path to query

Notes:

  • The driver calls connect() automatically on first fetch() if not connected.
  • fetch() yields arrays of documents in the shape { id: string, ...data }.

API

  • new FirestoreSourceDriver<T>(config: FirestoreConfig) — construct driver
  • connect(): Promise<void> — initialize Firebase app and Firestore client
  • fetch(): AsyncGenerator<Array<{id: string} & DocumentData>, void, unknown> — iterate batches
  • close(): Promise<void> — terminate Firestore client and reset state

Error handling

Driver operations may throw FirebaseError for invalid credentials, permission issues, or network errors. Use try/catch/finally and always call close() in a finally block to release resources.

License

MIT