@iamcalegari/mongoat / CreateModelProps
Interface: CreateModelProps<ModelType>
Defined in: src/types/model.ts:61
Type Parameters
ModelType
ModelType extends Document
Properties
allowedMethods?
optionalallowedMethods?:METHODS[]
Defined in: src/types/model.ts:62
collectionName?
optionalcollectionName?:string
Defined in: src/types/model.ts:68
Optional when schema is a class decorated with @Schema('name') — the decorated class provides a default collectionName. When provided here, it always overrides the class default.
documentDefaults?
optionaldocumentDefaults?:DocumentDefaults<ModelType>
Defined in: src/types/model.ts:69
hooks?
optionalhooks?:object
Defined in: src/types/model.ts:74
Declarative pre/post hook registration — merged BEFORE any later .pre()/.post() chainable calls (constructor hooks run first).
aggregate?
optionalaggregate?:HookConfig<BaseHookContext<ModelType> &object>
bulkWrite?
optionalbulkWrite?:HookConfig<BaseHookContext<ModelType> &object>
delete?
optionaldelete?:HookConfig<BaseHookContext<ModelType> &object>
deleteMany?
optionaldeleteMany?:HookConfig<BaseHookContext<ModelType> &object>
find?
optionalfind?:HookConfig<BaseHookContext<ModelType> &object>
findById?
optionalfindById?:HookConfig<BaseHookContext<ModelType> &object>
findMany?
optionalfindMany?:HookConfig<BaseHookContext<ModelType> &object>
insert?
optionalinsert?:HookConfig<BaseHookContext<ModelType> &object>
insertMany?
optionalinsertMany?:HookConfig<BaseHookContext<ModelType> &object>
total?
optionaltotal?:HookConfig<BaseHookContext<ModelType> &object>
update?
optionalupdate?:HookConfig<BaseHookContext<ModelType> &object>
updateMany?
optionalupdateMany?:HookConfig<BaseHookContext<ModelType> &object>
indexes?
optionalindexes?:CreateIndexProps[]
Defined in: src/types/model.ts:75
onHookError?
optionalonHookError?:OnHookError<BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object|BaseHookContext<ModelType> &object>
Defined in: src/types/model.ts:82
Fallback for fireAndForget post-hook rejections — a fireAndForget hook's error never propagates to the caller, so it is routed here instead. When omitted, the model falls back to console.error (never swallowed in total silence).
plugins?
optionalplugins?:Plugin<ModelType>[]
Defined in: src/types/model.ts:90
Local plugins for this model, applied after any global plugins and before the model is wrapped for method gating — so hooks/methods a plugin registers are already present on the very first construction. Global plugins always run first; within each group, plugins apply in declaration order.
schema
schema:
ModelValidationSchema<any> |SchemaClass<ModelType>
Defined in: src/types/model.ts:96
Accepts either a plain ModelValidationSchema object or a class decorated with @Schema/@Prop — the two schema declaration styles are interchangeable and compile to the same validator.
validationQueryExpressions?
optionalvalidationQueryExpressions?:ValidationQueryExpressions
Defined in: src/types/model.ts:97
validity?
optionalvalidity?:boolean
Defined in: src/types/model.ts:98