I am working on an aggregation pipeline to compile data to push to the frontend for a chart to render, which involves 3 collections (one of which is just a reference to the other 2). Individually on the collections, I am able to get the expected response on the aggregation, but when trying to incorporate the aggregations together with $lookup, I keep getting the error:
query failed: (Location40323) A pipeline stage specification object must contain exactly one field.
From what I’m reading in other user’s threads on this error, its either a missing bracket, or a property being set outside the appropriate bracket. However, for the life of me, I cannot find any missing brackets. I’m still learning mongoDB, and (coding in general…) so I’m certain its some silly mistake/oversight, but I’ve been running through the code over and over and coming up short. If anyone can help point out the errors I’m making, I’d greatly appreciate it.
I’ve made a playground with the example: