Hi @Nitin_Mukheja_1!
Thanks for posting your question. Here’s a Quick Start tutorial written by my colleague @nraboy on how to form an Aggregation Pipeline with MongoDB and Golang.
It seems that you declare your stages, then use the Aggregate
operation to execute your pipeline (sample code taken from linked quick start above):
matchStage := bson.D{{"$match", bson.D{{"podcast", id}}}}
groupStage := bson.D{{"$group", bson.D{{"_id", "$podcast"}, {"total", bson.D{{"$sum", "$duration"}}}}}}
showInfoCursor, err := episodesCollection.Aggregate(ctx, mongo.Pipeline{matchStage, groupStage})
Please let us know if this helps or if you have any other questions!