I am trying to get users in a certain age range via aggregation.
Edit: I am able to work through mongo shell, query works fine however I am not able to make it work with go
This code gives me "missing type in composite literal" error.
What am I missing here?
lte := 10
gte := 0
operations := []bson.M{
{
"$match":{
"$and":[]interface{}{
bson.M{"age":{"$gte":gte}},
bson.M{"age":{"$lte":lte}},
},
},
},
{
"$group":bson.M{"_id":"$user_id"},
},
}
r := []bson.M{}
pipe := c.Pipe(operations)
err := pipe.All(&r)
if err != nil {
logrus.Errorf("Error: %v", err)
return err
}
user_idand to prevent lengthy discussions. ;)