Now one quick note about sorting in the last lecture. I sorted on the price and if you do that often,
it is of course a good idea to create an index on the price in your products collection.
Now as I mentioned at the beginning of this module, creating such an index is not something you would
do from inside your node code because you won't do that
upon an incoming request or anything like that,
this code is really for your application logic, not for managing your database.
So if you want to do something like create that index, you should do it from inside the shell. There
you can of course say db products create index and then simply create an index on the price in ascending
or descending order,
doesn't matter what you use in your node app because the index can be traversed in both directions by the
mongo client.
So if I do that, now you see the index was added, we get a bit of more detailed output there than we did
before because we're using a slightly different setup here
but in the end we now added an index and now, we don't need to change anything here
in our node code, we also don't need to restart our node server,
we now just have an index added in case we did want to sort and we can of course comment that back
in even if we're not using pagination.
So that's just a side note,
if you do change some configuration or add an index, you would do that outside of this application.