FAQ
I got it working with the Run command:

pipeline := []bson.D{
bson.D{
{ "$match",
bson.M{
"visittime": bson.M{"$lt":to, "$gte":from},
},
},
},
bson.D{
{ "$group",
bson.M{
"_id": "$mxitid",
"count": bson.M{
"$sum": 1,
},
} },
},
bson.D {
{ "$sort", bson.M{ "count":-1 }},
},
}
query := bson.D{
{"aggregate","log"},
{"pipeline", pipeline},
}

var res interface{}
// Db() returns *mgo.Database
err = Db().Run(query, &res)
if nil!=err {
fmt.Fprintf(w, "ERR: %v", err)
} else {
fmt.Fprintf(w, "%v", res)
}

All the best,
C


--
You received this message because you are subscribed to the Google Groups "mgo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mgo-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupmgo-users @
categoriesmongodb
postedFeb 27, '13 at 1:12p
activeFeb 27, '13 at 4:49p
posts3
users2
websitelabix.org...
irc#mongodb

2 users in discussion

Craigmj: 2 posts Gustavo Niemeyer: 1 post

People

Translate

site design / logo © 2021 Grokbase