Order
Before defining the Order
model, let's first create the OrderStatus
enum.
And then, create the model.
Now, about the relations. A user
may have many orders
, and an order
belongs to one user
. It is a one-to-many relation. Let's begin at the user
side.
Then, the order
side. Note that the foreign key definition must be separate.
Let's now generate and run the migration through the process already known to us.
We'll then create the orders resource.
And perform the 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 - 5
In the UsersService
, in the findOne()
method, let's also fetch its orders
, by adding include
after the where
clause.
Commit - Creating order model
Last updated