And so, this will push this comment into the comment field of this specific dish.
So, now that we have modified the dish,
the next step that we're going to do is to,
let me close off this and then put that into it, then there.
I'm going to come back and fix that in a short while.
So, now that we have modified the dish,
we need to save the dish.
So, we'll say, "Return dish safe."
So, in this step,
we are inserting a comment into the dish,
the dish that we have just created and updated,
and then we are saving that comment;
and then, this will return the dish.
And when the dish is returned in the next callback,
I'm going to then say, "Console log dish."
And then, after that,
we will say, "Return."
So, with this, we have modified our index.js file.
Let's save the changes and look at this application.
Going to the terminal,
let's run npm start and then see the resulting value here.
So, going back, we see that in the first step,
we have created this dish here with the name and description as we have given earlier.
And then, once the dish is created,
in the second step,
we updated the dish and then printed out the updated version of the dish.
So, the updated version of the dish is printed out right there.
And you can see that the description has been updated from the previous case,
but the id remains exactly the same as the dish that we created earlier.
And the comments field,
as you can see here,
is an empty array and the smoked.
In third step, we push the comment into our dish here;
and then so, this particular comment that
we added has been added into this comments array.
So, you can see that comment being enclosed here,
and this is the updated dish that has now been printed onto the screen here.
So, you can see that we have done several steps one after another with our dish.
We first created the dish,
then we updated the dish,
then we inserted a comment into the dish,
which is a sub-document inside the dish document;
and then, we printed out the result to you.
With this, we complete this exercise.
In this exercise, we have seen how we can,
first, create a dish by using dishes create,
then we saw the use of sub-documents: there,
we defined a schema within the dishes.js
file and then use the comment schema that we defined and
then defined the field in the dishes schema as an array of the commentSchema type.
And then, in the index.js file,
we were able to create a dish,
update the dish and also push
a comment document into the dish and then save the changes here.
With this, we complete this exercise.
This is a good time for you to do a Git Kermit with the message, "Mongoose part three."