Which is of the type Number.
This is required and the default value, I will leave that as 5.
And the second property would be Comment, which is of the type string.
This is required and the default value is empty.
So each comment will have these two properties, rating and comment,
associated with it.
Also, we need to now define the relationship between the comment and
the user that is submitting the comment, and also the comment and
the dish with which this comment is associated.
Similarly, we have seen in the earlier exercise that they have added
their favorites for a user.
So to define the favorites, let me again define a model,
and that model name is Favorite and this is also saved in the MongoDB,
and this is also a PersistedModel, and
we will expose the favorite for the rest API and is in the common folder.
Now the favorite itself doesn't need any specific property because all of
the favorite does is associates the specific user with this specific dish.
So the favorite here is going to be used simply as a bridge between the user
and the dish.
So we will use the favorite as a way of defining relations between the dish and
a user.
So it doesn't have any specific properties.
So now we have added two models into our loopback server.
Now, let's start defining the model relations.
Now as I explained earlier,
there are various kinds of model relationships that we can define.
Let's start with defining the relationship between a dish and a comment.
So to define a model in loopback, we'll say, lb relation.
And when the relationship comes in,
we need to specify the model from which to create the relation.
So in the first instance, we will create a relation between a dish.
So from the dishes, and a dish might have many comments associated with it,
so that's why the relation type has many and
is associated with a comment and the property name for the relation
I will leave it as the default with just comment with a small letter c.