1 00:00:02,310 --> 00:00:05,070 So that's it for this module. 2 00:00:05,070 --> 00:00:10,610 We had a detailed look at the aggregation framework and the stages and operators it offers. 3 00:00:10,650 --> 00:00:15,420 There are plenty of available stages and operators as you saw and I can only encourage you to dive into 4 00:00:15,420 --> 00:00:21,360 the official docs which are awesome and have detailed examples for all of them to explore them all and 5 00:00:21,360 --> 00:00:26,340 play around with them because playing around with them with some dummy data really is the best thing 6 00:00:26,340 --> 00:00:27,920 you can do here. 7 00:00:27,990 --> 00:00:33,690 Now stages define the different steps through which your data is funneled and each stage receives the 8 00:00:33,690 --> 00:00:39,760 output of the last stage as the input, except for the first stage which interacts directly with your 9 00:00:39,800 --> 00:00:44,820 collection and which therefore can take advantage of indexes and so on, 10 00:00:44,820 --> 00:00:47,700 so the first stage has like a special role. 11 00:00:47,700 --> 00:00:53,970 Also keep in mind that mongodb automatically optimizes your pipeline behind the scenes to for example 12 00:00:53,970 --> 00:00:55,150 match early, 13 00:00:55,200 --> 00:01:01,530 you should still try to write good code and a good set up of pipeline stages to efficiently query your 14 00:01:01,530 --> 00:01:08,430 data and query before you use sort or project to avoid unnecessary sorting or projections on all the 15 00:01:08,430 --> 00:01:09,020 data 16 00:01:09,030 --> 00:01:12,100 if you planned to filter it down anyways. 17 00:01:12,660 --> 00:01:19,250 Now operators can be used inside of stages and which operator can be used where depends on the stage 18 00:01:19,350 --> 00:01:24,450 and you can really just get a feeling for that overtime as you do work with all these operators, the 19 00:01:24,450 --> 00:01:30,990 official docs again help you with that as they describe use cases for all operators. 20 00:01:31,030 --> 00:01:33,380 Now there are a couple of important stages, 21 00:01:33,580 --> 00:01:39,930 the most common stages you will work with are probably match, group, project, sort, unwind. 22 00:01:39,940 --> 00:01:45,340 Now of course all the other stages are good too and you should definitely use whatever is the right tool for 23 00:01:45,340 --> 00:01:49,630 the job you're trying to get done but you'll work with these stages a lot, 24 00:01:49,630 --> 00:01:55,440 so you should definitely make sure that you've got this set and that you understand what they do. 25 00:01:55,450 --> 00:02:02,200 There also are some common behaviors that are shared between find filters and projection and match and 26 00:02:02,200 --> 00:02:05,810 project which are kind of the equivalence in the aggregation framework 27 00:02:05,860 --> 00:02:11,800 but keep in mind that in the aggregation framework, especially project is way more flexible and can do 28 00:02:11,800 --> 00:02:18,350 way more things like add new fields, recalculate, a lot of stuff that you can't do 29 00:02:18,520 --> 00:02:21,630 in the projection in the find method. 30 00:02:21,640 --> 00:02:28,210 So with that, I really encourage you to dive into the docs, pick some dummy data, maybe the data we use 31 00:02:28,210 --> 00:02:32,100 here or some other data and play around with these stages 32 00:02:32,140 --> 00:02:38,970 and these operators. This is the best way you can learn how to use the aggregation framework.