Skip to main content
The 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 ParamOption object 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

Generates routes like:
  • GET /users/:id
  • PATCH /users/:id
  • DELETE /users/:id

Numeric Primary Key

Composite Parameters (Nested Resources)

Generates routes like:
  • GET /users/:userId/posts
  • GET /users/:userId/posts/:id
  • POST /users/:userId/posts
  • PATCH /users/:userId/posts/:id

Custom Field Mapping

Generates routes like:
  • GET /articles/:slug (uses urlSlug field for lookup)

Enum Parameters

Disabled Parameters

ParamOptionType

The ParamOptionType 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.
Make sure your route path matches your parameter configuration. If you define a parameter userId in params, your controller route should include :userId in the path.

CrudOptions

Main CRUD configuration

ModelOptions

Configure entity model