Skip to Content
DocsNestJS CRUD AutomatorAPI ReferenceDecoratorsFunction DecoratorsFunction Decorators

Function Decorators

Function decorators wrap repository operations inside services, applying DTO validation, subscriber hooks, and standardized error handling for every CRUD action.

Available decorators

DecoratorPurposeReference
@ApiFunctionEntry point that selects the correct CRUD decorator based on type./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function
@ApiFunctionCreatePersists new records with subscriber before/after hooks and error propagation./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-create
@ApiFunctionDeleteDeletes records using criteria DTOs, handling transactional repositories when provided./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-delete
@ApiFunctionGetFetches a single entity instance with guard-friendly errors./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-get
@ApiFunctionGetListRetrieves paginated collections with filtering, sorting, and projection metadata./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-get-list
@ApiFunctionGetManyOptimized multi-id fetch with guard-aware error handling./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-get-many
@ApiFunctionUpdateUpdates entities with DTO validation, transactional repository support, and subscribers./docs/nestjs-crud-automator/api-reference/decorators/api-function/api-function-update

Usage guidelines

  1. Ensure the decorated service exposes a repository property compatible with TypeORM repositories.
  2. Choose the specific decorator when you want direct control, or use @ApiFunction with type to route automatically.
  3. Pass EntityManager instances into decorated methods when wrapping operations inside explicit transactions.
Last updated on