Comfort writing queries

How to comfort up writing process of queries of aggregation? It’s maximum discomfort when i trying to type something like this in console: var pipeline = [{"$project":{"sameAuthors":{"$setInteersection":["cast":{"$map":{input:"$cast",as:"i",in:{"$arrayElemAt":[{"$split":["$$i"," ("],0}]}}},"directors":{$map:{input:"$directors",as:"director",in:{$arrayElemAt:[{$split:["$$director"," ("]},0]}}},"writers":{$map:{input:"$writers",as:"writer",in:{$arrayElemAt:[{$split:["$$writer"," ("]},0]}}}]}}}, {$match:{sameAuthors:{$elemMatch:{$exists:true}}}}]

Please read MongoError: A pipeline stage specification object must contain exactly one field - #15 by steevej

Use the MongoDB Compass aggregation pipeline builder:

Or the same thing directly in Atlas in the collection tab.

That makes sense, thank you!

1 Like

I find Pipeline Buider useful, but i wanted something like variables, that @steevej told me. Thank you too.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.