Documentation
Generate a typed model with framework-correct imports and collection metadata.
model creates one TypeScript model using paths and the runtime package from
fireclass.json.
fireclass model [options] <name>The name argument may use PascalCase, kebab-case, snake_case, or spaces.
| Option | Description |
|---|---|
-c, --collection <name> | Override the generated Firestore collection name. |
--dir <path> | Override the configured models directory for this file. |
--force | Overwrite an existing model file. |
-h, --help | Print command help. |
The command derives three values:
| Input | Class | File | Default collection |
|---|---|---|---|
User | User | user.ts | users |
user-profile | UserProfile | user-profile.ts | userprofiles |
Category | Category | category.ts | categories |
Status | Status | status.ts | status |
Collection pluralization is intentionally simple: lowercase the class name,
keep names ending in s, change a final y to ies, otherwise append
s. Use --collection whenever the desired Firestore name differs.
For a React project, fireclass model User produces:
import { Collection } from "@dharayush7/fireclass-react";
import { BaseModel } from "../lib/fireclass";
@Collection("users")
export class User extends BaseModel<User> {
createdAt?: Date;
constructor(data?: Partial<User>) {
super(data);
Object.assign(this, data);
}
}The SDK import follows config.package. The BaseModel import is calculated
relative to fireclass.path, even when --dir changes the output location.
Express projects use a .js suffix on that relative import for Node ESM.
The generated model is deliberately minimal. Add fields and
class-validator decorators after generation.
npx fireclass model Usernpx fireclass model user-profile --collection user_profilesnpx fireclass model Order --dir src/entitiesnpx fireclass model Order --force--force replaces the whole file
The generator does not merge fields or decorators. Review source control before overwriting a model that has been edited.
Without --force, an existing target file is left untouched and the command
exits non-zero. It also fails when no project root or readable
fireclass.json can be found.
--dir changes only this invocation; it does not update
models.dir in fireclass.json.
Use list after generation to inspect the model and collection that the CLI can discover.