Relative Content

Tag Archive for mongodbgobson

mongodb aggregation in Go

db.templates.aggregate([{$sort:{accountid:1,sessionid:1,templateid:1}},{$group:{_id:{accountid:”$accountid”,sessionid:”$sessionid”,templateid:”$templateid”},dups:{$push:”$_id”},count:{$sum:1}}},{$match:{count:{$gt:1}}}],{allowDiskUse:true}).forEach((function(e){e.dups.shift(),db.templates.remove({_id:{$in:e.dups}})})); I’ve got this mongodb query which work perfect but I need to carry this to Golang so I could do c, err := coll.Aggregate(ctx, mongo.Pipeline{groupStage}) like they do it here -> https://www.mongodb.com/docs/drivers/go/current/fundamentals/aggregation/ but apparently I am too stupid to do it.Ive tried something like this one but it doesn’t work. groupStage := bson.D{ {“$group”, […]