Static OptionalprormStatic OptionalmodelStatic OptionaltableStatic OptionalschemaStatic OptionalrawStatic OptionalassociationsStatic OptionaloptionsStatic OptionalprimaryStatic Optional_Static Optional_Associations declared via User.hasMany(...)/.belongsTo(...)/etc before the model has been registered with prorm.addModel(). Queued here and replayed by Prorm.addModel() once the model (and its prorm/models[name] entry) exists, so association calls can be made either before or after addModel().
Static Optional_Scopes added via User.addScope(...) before the model has been registered with prorm.addModel(). Merged into the model's options.scopes by Prorm.addModel() so addScope() can be called either before or after addModel().
StaticaddStatichasOptionaloptions: anyStaticbelongsOptionaloptions: anyStatichasOptionaloptions: anyStaticbelongsOptionaloptions: anyStaticgetStaticgetStaticgetStaticcreateCreate a database view over this model.
A view is a saved query, and this is that query written against the model
it selects from — so from is implied and can be left out:
await Customer.createView('customer_info', {
attributes: ['firstName', 'lastName', 'email'],
where: { country: 'USA' },
});
Pass from anyway to select from somewhere else while keeping the call on
this model. Omit the definition entirely for a view of the whole table.
Name of the view to create
Query options; from defaults to this model
Optionaloptions: Record<string, unknown>
View options, e.g. { replace: true }
StaticcreateCreate a materialized view over this model. As createView, with
from defaulting to this model.
Name of the materialized view
Query options; from defaults to this model
Optionaloptions: Record<string, unknown>
Materialized view options, e.g. { uniqueIndex }
StaticdropDrop a view created from this model.
Name of the view to drop
Optionaloptions: Record<string, unknown>
Drop options, e.g. { ifExists: false }
StaticfindOptionalfindOptions: FindOptionsStaticfindOptionalfindOptions: FindOptionsStaticfindOptionaloptions: FindOptionsStaticfindStaticfindStaticfindStaticgetGet the model attribute name for a database column (static version)
The database column name
The model attribute name (or the column name if no mapping exists)
StaticbuildOptionalvalues: Record<string, any>Optionaloptions: Record<string, any>StaticcreateOptionalvalues: Record<string, any>Optionaloptions: CreateOptionsStaticupdateStaticdestroyStaticcountOptionaloptions: CountOptionsStaticbulkOptionaloptions: BulkCreateOptionsStaticupsertOptionaloptions: UpsertOptionsStatichookStaticaddStaticbeforeStaticafterStaticbeforeStaticafterStaticbeforeStaticafterStatichasCheck if a hook is registered on the model
The name of the hook (e.g., 'beforeCreate', 'afterSave')
True if the hook is registered, false otherwise
StatichasCheck if a hook is registered on the model (alias for hasHook)
The name of the hook (e.g., 'beforeCreate', 'afterSave')
True if the hook is registered, false otherwise
StaticremoveRemove a hook from the model
The name of the hook (e.g., 'beforeCreate', 'afterSave')
OptionalhookOrHookId: string | HookHandler
Optional: The specific hook callback function OR hook ID to remove. If not provided, removes all hooks of this type
The model for chaining
Base Model class for decorator-based model definitions
This class can be extended to create models using TypeScript decorators:
Example