Category

We'll now create the Category model, following the same protocol.

model Category {
  id Int @id @default(autoincrement())

  name String @unique

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Then generate and run the migration, as the relations cannot be set yet.

yarn migrate:create create-category
yarn migrate:run

Create the categories resource

nest g res domain/categories

And perform the steps to finish its assembly

  • Exclude the entities folder

  • In the controller, use the IdDto wherever id is being used

  • Remove the number conversion operator (+) below each occurrence

  • Use PaginationDto in the findAll() method (and also in the service)

    • Default page size - 30

Commit - Creating category model

Last updated