But then on the same optional lab I ran into another error with $map in an example copied from the course:
`"errmsg" : "unknown operator: $map"`
These errors are really killing my motivation for the course. I need a lifeline.
Also, since my issue is with the syntax, to post my solutions asking for guidance would run afoul of the pinned notice about posting potential answers.
If you need to post part of a pipeline and want to avoid spoilers, you can hide a section of your post with [spoiler]Content to hide{/spoiler]:
Share MongoDB University questions in the course-based MongoDB Community Forums to get assistance
Spoilers require a click to reveal.
You could also share error messages without the full pipeline, which may be enough for someone to suggest a hint on how to resolve the issue. I would also include the specific version of MongoDB server you are using, as some errors may be related to syntax not supported in your version of MongoDB.
I’d try to persist and continue asking for advice in the forums. I highly recommend using the Aggregation Pipeline Builder in MongoDB Compass to build and troubleshoot your pipelines. The Pipeline Builder includes some examples of syntax with links to the relevant documentation and also has an option to preview results as you build your aggregation pipeline. I personally find it a huge time saver (especially for complicated aggregations), and you can also save aggregations for later reuse or export to driver syntax (Python, Java, Node, or C#).
Although the $-prefixed aggregation commands look similar, there are two contexts to consider:
Aggregation Pipeline Stages fetch, filter, or reshape documents. The output of each aggregation stage is used as input for the following aggregation stage.
Aggregation Pipeline Operators (for example $map and $setIntersection) are expressions used within an aggregation stage to manipulate fields and values within documents.
Those are my own characterisations and may not be enough clarity for a mental model of stages versus operators. However, if you use the Aggregation Pipeline Builder it will only let you add valid stages to a pipeline.