Skip to content

@iamcalegari/mongoat / CreateModelProps

Interface: CreateModelProps<ModelType> ​

Defined in: src/types/model.ts:61

Type Parameters ​

ModelType ​

ModelType extends Document

Properties ​

allowedMethods? ​

optional allowedMethods?: METHODS[]

Defined in: src/types/model.ts:62


collectionName? ​

optional collectionName?: 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? ​

optional documentDefaults?: DocumentDefaults<ModelType>

Defined in: src/types/model.ts:69


hooks? ​

optional hooks?: 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? ​

optional aggregate?: HookConfig<BaseHookContext<ModelType> & object>

bulkWrite? ​

optional bulkWrite?: HookConfig<BaseHookContext<ModelType> & object>

delete? ​

optional delete?: HookConfig<BaseHookContext<ModelType> & object>

deleteMany? ​

optional deleteMany?: HookConfig<BaseHookContext<ModelType> & object>

find? ​

optional find?: HookConfig<BaseHookContext<ModelType> & object>

findById? ​

optional findById?: HookConfig<BaseHookContext<ModelType> & object>

findMany? ​

optional findMany?: HookConfig<BaseHookContext<ModelType> & object>

insert? ​

optional insert?: HookConfig<BaseHookContext<ModelType> & object>

insertMany? ​

optional insertMany?: HookConfig<BaseHookContext<ModelType> & object>

total? ​

optional total?: HookConfig<BaseHookContext<ModelType> & object>

update? ​

optional update?: HookConfig<BaseHookContext<ModelType> & object>

updateMany? ​

optional updateMany?: HookConfig<BaseHookContext<ModelType> & object>


indexes? ​

optional indexes?: CreateIndexProps[]

Defined in: src/types/model.ts:75


onHookError? ​

optional onHookError?: 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? ​

optional plugins?: 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? ​

optional validationQueryExpressions?: ValidationQueryExpressions

Defined in: src/types/model.ts:97


validity? ​

optional validity?: boolean

Defined in: src/types/model.ts:98