How can I write a similar query in golang (mgo)?
db.result.aggregate([{
$lookup: {
from: "session",
localField: "session.id",
foreignField: "_id",
as: "session_info"
}
}]).forEach(function(d){db.result.insert(d)})
First I have got this, but I don't know how to insert the result into the same collection...
var results []AggregateData
pipe := d.Pipe([]bson.M{
bson.M{"$lookup": bson.M{
"from": "session",
"localField": "session.id",
"foreignField": "_id",
"as": "session_info",
}},
}).All(&results)
Maybe I could iterate over the results and insert it into the collection, but it would slow down my application.