Deprecated Firebase Admin model package. Migrate to the current Fireclass runtime for Node.js, Next.js, or React.
Migration guide | Current packages | GitHub | npm
Deprecated: Do not use this package for new applications. It is retained for existing Firebase Admin projects. The current Fireclass suite provides runtime-specific packages, typed errors, broader query support, testing utilities, Next.js boundaries, and React realtime hooks.
| Application | Current package |
|---|---|
| Node.js, Express, workers, Cloud Functions | @dharayush7/fireclass-js |
| Next.js App Router | @dharayush7/fireclass-ssr |
| React with Firebase client Firestore | @dharayush7/fireclass-react |
| Custom adapters and in-memory tests | @dharayush7/fireclass-core |
For a Node or Express application:
npm remove @dharayush7/fireclass
npm install @dharayush7/fireclass-js firebase-admin class-validator class-transformer reflect-metadataThen follow the complete migration guide.
Replace the legacy subpath factory:
- import { getBaseModel } from "@dharayush7/fireclass/core";
+ import { createFireclass } from "@dharayush7/fireclass-js";
- export const BaseModel = getBaseModel(firestore);
+ export const { BaseModel, adapter } = createFireclass(firestore);The current Node runtime still exports getBaseModel(firestore) as an
intermediate migration alias.
Remove legacy /decorators, /core, and
/types imports:
- import { Collection } from "@dharayush7/fireclass/decorators";
- import type { QueryOptions } from "@dharayush7/fireclass/types";
+ import {
+ Collection,
+ type QueryOptions,
+ } from "@dharayush7/fireclass-js";Import SDK decorators and standalone helpers directly where they are used. Keep
the local initialized Fireclass file limited to BaseModel and the
adapter.
| Area | Legacy package | Current suite |
|---|---|---|
| Validation errors | Raw validation rejection | ValidationFailedError with errors |
| Missing collection | Generic error | MissingCollectionError |
| Delete without id | Generic error | MissingIdError |
Instance delete() |
Returns deleted id | Returns void |
findMany() |
Query required | Query optional |
| Query operators | Equality and ranges | Adds in, not-in, array, cursor, find-one, and count |
| Testing | Firebase Admin required | In-memory FakeAdapter available |
| Next.js | No server/client guard | Dedicated server-only SSR package |
| React | Not supported | Dedicated client package and realtime hooks |
The equality filter is equals, not equal.
The following section is retained only for applications that cannot migrate immediately.
npm install @dharayush7/fireclass firebase-admin class-validator class-transformer reflect-metadataRequirements:
- Node.js 18 or newer.
- Firebase Admin Firestore.
- TypeScript decorators enabled.
- A model constructor that calls
super(data)and assigns data.
import "reflect-metadata";
import { cert, getApps, initializeApp } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";
import { getBaseModel } from "@dharayush7/fireclass/core";
if (getApps().length === 0) {
initializeApp({
credential: cert({
projectId: process.env.FIREBASE_PROJECT_ID,
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, "\n"),
}),
});
}
export const firestore = getFirestore();
export const BaseModel = getBaseModel(firestore);Keep service-account values in gitignored environment files or a managed secret store.
import { Collection } from "@dharayush7/fireclass/decorators";
import { IsEmail, IsOptional, IsString, Length } from "class-validator";
import { BaseModel } from "./fireclass";
@Collection("users")
export class User extends BaseModel<User> {
@IsString()
@Length(2, 80)
name!: string;
@IsEmail()
email!: string;
@IsOptional()
@IsString()
displayName?: string;
constructor(data?: Partial<User>) {
super(data);
Object.assign(this, data);
}
}Legacy operations:
const id = await new User({
name: "Ada Lovelace",
email: "ada@example.com",
}).save();
const user = await User.findById(id);
const users = await User.findMany({
where: { email: { equals: "ada@example.com" } },
orderBy: { name: "asc" },
limit: 20,
});
await user?.delete();- Choose the runtime package.
- Replace initialization and legacy subpath imports.
- Update validation error handling.
- Review instance delete return values.
- Review new query capabilities and Firestore indexes.
- For Next.js, move Admin models behind the SSR server-only boundary.
- Run the Fireclass CLI diagnostics and application tests.
npx fireclass init
npx fireclass doctor
npm run typecheck
npm testChanging packages does not rewrite Firestore documents. Existing collection
names remain controlled by @Collection, but application schema
changes must be handled separately.
See CHANGELOG.md for version history and RELEASE_NOTES.md for the current release summary.
- Website: fireclass.ayushdhar.com
- Portfolio: ayushdhar.com
- Email: contact@ayushdhar.com
MIT. Copyright Ayush Dhar.
{ "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true } }