Registry / database / firestore-repository

firestore-repository

JSON →
library0.5.0jsnpmunverified

A minimal, type-safe Firestore ORM implementing the Repository Pattern for TypeScript. Current stable version is 0.5.0, released as needed (no fixed cadence). It provides universal code sharing between backend (Node.js with @google-cloud/firestore) and frontend (web with @firebase/firestore) via adapter packages. Unlike heavier ORMs like Fireorm, it stays close to the official Firestore vocabulary, adds compile-time schema validation, and supports auto-completion for field paths in queries.

npm install firestore-repository
INSTALL
IMPORT
SIG · FIRESTORE-REPOSITO
F
firestore-repository
databasejavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rootCollection
import { rootCollection } from 'firestore-repository/schema'
import { rootCollection } from 'firestore-repository'
rootCollection is exported from the schema subpath; importing from main entry will fail.
string
import { string } from 'firestore-repository/schema'
import { string } from 'firestore-repository'
Schema type helpers are in firestore-repository/schema, not the main entry.
rootCollectionRepository
import { rootCollectionRepository } from '@firestore-repository/google-cloud-firestore'
import { rootCollectionRepository } from 'firestore-repository'
Repository constructors are provided by adapter packages, not the core library.

Defines a Users collection with a typed schema, creates a repository, and performs a create & get operation.

import { rootCollection, string, double, optional, literal, array } from 'firestore-repository/schema'; import { rootCollectionRepository } from '@firestore-repository/google-cloud-firestore'; import { Firestore } from '@google-cloud/firestore'; const db = new Firestore(); const users = rootCollection({ name: 'Users', schema: { name: string(), profile: { age: double(), gender: optional(literal('male', 'female')) }, tag: array(string()), }, }); const repo = rootCollectionRepository(db, users); await repo.create({ ref: 'user1', data: { name: 'John', profile: { age: 30 }, tag: ['a'] } }); const doc = await repo.get('user1'); console.log(doc?.data?.name);
Debug
Known issues
breakingRequires Node.js >=18
fix
Update Node.js to version 18 or later.
affects: >=0.5.0
gotchaThe core firestore-repository package does not include runtime dependencies for Firestore. You must install an adapter package separately.
fix
Install exactly one adapter: @firestore-repository/google-cloud-firestore for backend or @firestore-repository/firebase-js-sdk for frontend.
affects: >=0.0.0
gotchaSchema functions (string, double, etc.) must be called (e.g., string()) not referenced bare.
fix
Use string(), double(), etc. as functions.
affects: >=0.0.0
deprecatedThe legacy import path 'firestore-repository' may be removed in future versions. Use subpath imports.
fix
Import from 'firestore-repository/schema' and adapter packages directly.
affects: >=0.5.0
Errors
Common errors & fixes
Cannot find module '@firestore-repository/google-cloud-firestore' or its corresponding type declarations.
Adapter package not installed or missing from package.json.
fix
Run `npm install @firestore-repository/google-cloud-firestore`.
Module 'firestore-repository' has no exported member 'rootCollection'.
Importing from wrong path; rootCollection is in 'firestore-repository/schema'.
fix
Change import to: `import { rootCollection } from 'firestore-repository/schema'`.
TypeError: string is not a function
Schema type helpers must be called as functions.
fix
Use `string()` instead of `string`.
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
@firestore-repository/google-cloud-firestorerequiredBackend adapter required for server-side Firestore access
@firestore-repository/firebase-js-sdkoptionalWeb adapter required for client-side Firestore access via Firebase SDK
Agent activity
4 hits · last 30 days
node
4
Resources
firestore-repository — npm install firestore-repository · libregistry