Prerequisites
Make sure you have completed the installation steps and have a NestJS project set up with TypeORM and NestJS CRUD installed.Create your first CRUD API
1
Create an entity
Create a TypeORM entity to define your data model. Add validation decorators from
class-validator:User.entity.ts
2
Create a service
Create a service that extends That’s it! The
TypeOrmCrudService to handle database operations:users.service.ts
TypeOrmCrudService provides all CRUD methods out of the box.3
Create a controller
Create a controller with the The
@Crud() decorator to automatically generate REST endpoints:users.controller.ts
@Crud() decorator automatically creates these endpoints:GET /users- Get all usersGET /users/:id- Get one userPOST /users- Create userPOST /users/bulk- Create multiple usersPATCH /users/:id- Update userPUT /users/:id- Replace userDELETE /users/:id- Delete user
4
Register the module
Register your entities and services in a NestJS module:
users.module.ts
Test your API
Start your NestJS application and test the auto-generated endpoints:Advanced querying
NestJS CRUD provides powerful query capabilities out of the box. Try these advanced queries:Filter operators
NestJS CRUD supports a wide range of filter operators:Configure query options
Customize the query behavior in your controller:users.controller.ts
Override endpoints
You can override any auto-generated endpoint to add custom logic:users.controller.ts
Next steps
Query parameters
Learn about all available query parameters and filtering options
Controllers
Understand CRUD controllers and configuration options
Services
Dive deeper into CRUD services and custom implementations
Advanced features
Explore authentication, serialization, and Swagger integration