Registry / database / fireorm

fireorm

JSON →
library0.23.3jsnpmunverified

fireorm is a lightweight ORM wrapper around firebase-admin for Firestore, version 0.23.3 (latest). It provides a repository pattern on top of Firestore, abstracting CRUD operations with decorators like @Collection. Unlike raw Firestore SDK, fireorm lets you define models as TypeScript classes and persist them without writing collection references. It is community-maintained, with infrequent releases, and relies on reflect-metadata for decorator support. Currently stable but not actively developed; use with caution for new projects.

npm install fireorm
INSTALL
IMPORT
SIG · FIREORM
F
fireorm
databasejavascriptv0.23.3
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.

Collection
import { Collection } from 'fireorm'
const { Collection } = require('fireorm')
ESM default; require() may work but not recommended. TypeScript definitions are included.
getRepository
import { getRepository } from 'fireorm'
import getRepository from 'fireorm'
getRepository is a named export, not default.
initialize
import { initialize } from 'fireorm'
import * as fireorm from 'fireorm'; fireorm.default.initialize()
initialize is a named export, not on default.
FirestoreRepository
import { FirestoreRepository } from 'fireorm'
import { FirestoreRepository } from 'fireorm/lib/BaseFirestoreRepository'
Export is directly from 'fireorm', not a subpath.

Demonstrates initialization, model definition with @Collection, and CRUD operations using getRepository.

import * as admin from 'firebase-admin'; import { initialize, Collection, getRepository } from 'fireorm'; import 'reflect-metadata'; const serviceAccount = require('./firestore.creds.json'); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: `https://${serviceAccount.project_id}.firebaseio.com` }); const firestore = admin.firestore(); initialize(firestore); @Collection() class Todo { id: string; text: string; done: boolean; } const repo = getRepository(Todo); const todo = new Todo(); todo.text = 'Test fireorm'; todo.done = false; const saved = await repo.create(todo); console.log('Created todo with id:', saved.id); const found = await repo.findById(saved.id); console.log('Found:', found.text);
Debug
Known issues
breakingfireorm v0.9.0 changed the initialize function signature; it now expects a Firestore instance instead of admin.firestore() directly.
fix
Update code to call initialize(firestore) where firestore is the Firestore instance obtained from admin.firestore().
affects: >=0.9.0
deprecatedThe @SubCollection decorator was marked deprecated in v0.11.0 and may be removed in future versions.
fix
Use separate collections with references instead of subcollections.
affects: >=0.11.0
gotchafireorm requires reflect-metadata to be imported before using any decorators; failure to do so results in a 'Reflect.metadata is not a function' error.
fix
Add import 'reflect-metadata' at the top of your entry file.
affects: *
gotchafireorm does not support DocumentReference or GeoPoint out of the box; complex types require manual conversion using @Type decorator from class-transformer.
fix
Import { Type } from 'class-transformer' and decorate fields with @Type(() => GeoPoint) etc.
affects: <=0.23.3
breakingfireorm v0.8.0 changed the repository methods to return Promise<Entity> instead of Promise<void> for create/update; existing code may break if relying on void return.
fix
Update code to handle returned entity, e.g., const saved = await repo.create(todo);
affects: >=0.8.0
gotchafireorm queries via getRepository do not support transactions; all calls are standalone Firestore operations.
fix
Use raw firebase-admin Firestore for transactions if needed.
affects: <=0.23.3
Errors
Common errors & fixes
Reflect.metadata is not a function
reflect-metadata shim is not imported or loaded before fireorm decorators are used.
fix
Add 'import 'reflect-metadata'' at the very top of your entry file, before any fireorm imports.
TypeError: Cannot read property 'collection' of undefined
fireorm.initialize() was not called or was called with an invalid Firestore instance.
fix
Ensure you call initialize(firestore) with a valid admin.firestore() instance after Firebase app initialization.
Entity must have an id field
Missing 'id' property on the model class or the field is not declared as a string.
fix
Add 'id: string;' to your model class. The id is automatically generated if not set, but the field must exist.
Repository not found for entity
The entity class was not decorated with @Collection() or the module was not loaded before calling getRepository.
fix
Ensure the class has @Collection() decorator and that the module is imported early enough.
Upgrade
Version history
0.23.3latest on npm
Audit
Dependencies
reflect-metadatarequiredRequired for decorators and reflection metadata used by fireorm
Agent activity
39 hits · last 30 days
node
38
Resources