ParamsOptions interface allows you to configure URL path parameters used in CRUD operations, including their types, validation, and mapping to entity fields.
Interface Definition
Structure
ParamsOptions is a key-value object where:
- Key: The parameter name as it appears in the URL (e.g.,
id,userId,companyId) - Value: A
ParamOptionobject that configures how that parameter behaves
ParamOption Properties
string
The entity field name that this parameter maps to.If not specified, defaults to the parameter name.
ParamOptionType
The data type of the parameter for validation and parsing.Common values:
'number': Numeric ID'uuid': UUID string'string': Generic string
SwaggerEnumType
Enum type for Swagger documentation and validation.This will generate proper enum documentation in Swagger and validate that the parameter matches one of the enum values.
boolean
Indicates whether this parameter represents the primary key.The primary parameter is used for single-record operations (getOne, updateOne, deleteOne, etc.).
boolean
If
true, this parameter is disabled and won’t be used in queries.Usage Examples
Basic UUID Primary Key
GET /users/:idPATCH /users/:idDELETE /users/:id
Numeric Primary Key
Composite Parameters (Nested Resources)
GET /users/:userId/postsGET /users/:userId/posts/:idPOST /users/:userId/postsPATCH /users/:userId/posts/:id
Custom Field Mapping
GET /articles/:slug(usesurlSlugfield for lookup)
Enum Parameters
Disabled Parameters
ParamOptionType
TheParamOptionType from @nestjsx/crud-request typically includes:
'number': Validates and parses as a number'string': Treats as a string (no parsing)'uuid': Validates UUID format
Notes
If you don’t specify a
field property, the parameter name will be used as the field name. For example, params: { id: { type: 'uuid', primary: true } } assumes the entity has an id field.Related Configuration
CrudOptions
Main CRUD configuration
ModelOptions
Configure entity model