Answer the question
In order to leave comments, you need to log in
Why doesn't aggregation work in MGO?
Good afternoon, comrades. I recently started working with Go and the task was to pull some data out of mongi. I made such a simple pipeline for selecting by date:
fromDateS := time.Date(2017, time.July, 2, 0, 0, 0, 0, time.UTC)
toDateS := time.Date(2019, time.July, 2, 0, 0, 0, 0, time.UTC)
pipeline := []bson.M{
bson.M{
"$match": bson.M{
"ReceivedTime": bson.M{
"$gt": fromDateS,
"$lt": toDateS,
},
},
},
}
pipe := collection.Pipe(pipeline)
var results []Record
err = collection.Find(pipe).All(&results)
fromDateS := time.Date(2017, time.July, 2, 0, 0, 0, 0, time.UTC)
toDateS := time.Date(2019, time.July, 2, 0, 0, 0, 0, time.UTC)
var results []Record
err = collection.Find(bson.M{
"ReceivedTime": bson.M{
"$gt": fromDateS,
"$lt": toDateS,
},
}).All(&results)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question