Chapter 1: Basic Aggregation - $match and $project
Optional Lab - Expressions with $project
I tried this solution:
- In the stage1 ($match), I am checking that the writers, cast and directors fields exist
- In stage2 ($project), I am transforming the
writersto remove the text with " (…)"
- In stage3 ($project), I am using $map on
castand for each cast member I am checking if exists in ($in) the transformed
directorsarrays. The newly created array of booleans are stored in a new field,
- In the last stage ($match), checking if
matchedfield from previous stage has a
itcount gives the result correctly.
Is this solution acceptable? I see the actual answer uses different solution (I had no idea such array element comparison operator existed). Is there a disadvantage to the solution I made? If so what are they?
P.S.: I hope I am not breaking this rule: " [NOTICE] Please do not post potential answers in the forums"