Chapter 2: Basic aggregation

Lecture 1: $addFields stage operator
At the end of lecture both $project and $addFields stages are used to get selected fields (by $project) and transformed fields (by $addFields).
My question is: since $project can create new transformed fields like $addFields, is $addFields still necessary in such a case?
Thank you

Yes. With $project only the fields specified are passed to the next stage. With $addField only the added fields are needed simplifying the pipeline.

1 Like