User model
The first entity will be created, but now using Prisma instead of TypeORM.
Inside the file schema.prisma, we shall then create our first model, for User
. It is similar to the entity class that would receive TypeORM decorators. Let's then add the following.
model User {
id Int @id @default(autoincrement())
name String
email String @unique
phone String @unique
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
Then, generate and run the respective migration.
yarn migrate:create create-user
yarn migrate:run
Now, create the users resource once again.
nest g res domain/users
And perform the following steps to finish its assembly
Exclude the entities folder
In the controller, use the
IdDto
whereverid
is being usedRemove the number conversion operator (
+
) below each occurrenceUse
PaginationDto
in thefindAll()
method (and also in the service)Default page size - 10
Commit - Creating user model
If you wish to have validation, follow the section in the Core module, as it's identical. The same can be done with pagination, and also with the following decorators (for better organization in subsequent lessons)
@IsCardinal()
@IsEntity()
@IsCurrency()
Commit - Auxiliary structure
Last updated