1 00:00:02,110 --> 00:00:08,560 Now one quick note about sorting in the last lecture. I sorted on the price and if you do that often, 2 00:00:09,310 --> 00:00:14,590 it is of course a good idea to create an index on the price in your products collection. 3 00:00:14,620 --> 00:00:19,210 Now as I mentioned at the beginning of this module, creating such an index is not something you would 4 00:00:19,210 --> 00:00:22,370 do from inside your node code because you won't do that 5 00:00:22,390 --> 00:00:25,170 upon an incoming request or anything like that, 6 00:00:25,210 --> 00:00:29,740 this code is really for your application logic, not for managing your database. 7 00:00:29,830 --> 00:00:36,230 So if you want to do something like create that index, you should do it from inside the shell. There 8 00:00:36,250 --> 00:00:44,740 you can of course say db products create index and then simply create an index on the price in ascending 9 00:00:44,740 --> 00:00:45,940 or descending order, 10 00:00:45,940 --> 00:00:50,780 doesn't matter what you use in your node app because the index can be traversed in both directions by the 11 00:00:50,780 --> 00:00:52,310 mongo client. 12 00:00:52,330 --> 00:00:59,220 So if I do that, now you see the index was added, we get a bit of more detailed output there than we did 13 00:00:59,220 --> 00:01:02,340 before because we're using a slightly different setup here 14 00:01:02,370 --> 00:01:06,740 but in the end we now added an index and now, we don't need to change anything here 15 00:01:06,750 --> 00:01:10,550 in our node code, we also don't need to restart our node server, 16 00:01:10,590 --> 00:01:15,870 we now just have an index added in case we did want to sort and we can of course comment that back 17 00:01:15,900 --> 00:01:18,040 in even if we're not using pagination. 18 00:01:18,120 --> 00:01:19,300 So that's just a side note, 19 00:01:19,380 --> 00:01:25,300 if you do change some configuration or add an index, you would do that outside of this application.