ModelOptions interface specifies the entity/model class that the CRUD controller will operate on. This is the only required option when configuring a CRUD controller.
Interface Definition
Properties
any
required
The entity class that represents your data model.This should be a TypeORM entity, Mongoose model, or any other ORM entity class that your service layer can work with.
Usage Examples
Basic TypeORM Entity
With TypeORM Entity Definition
user.entity.ts
users.controller.ts
With Complete CRUD Configuration
Entity Requirements
The entity class specified inmodel.type should:
- Be decorated with ORM decorators (e.g.,
@Entity()for TypeORM) - Have a primary key field (e.g.,
@PrimaryGeneratedColumn()or@PrimaryColumn()) - Have columns/properties that map to database fields
- Be registered in your ORM module configuration
TypeORM Entity Example
Mongoose Model Example
Notes
The
model.type property is the only required field in the entire CrudOptions configuration. All other options have sensible defaults.Related Configuration
CrudOptions
Main CRUD configuration
ParamsOptions
Configure entity parameters