Hello fella gophers! I am trying to nest a pipeline inside $lookup stage in MongoDB 5 using Go driver, but I got this error:
"(AtlasError) Expected 'pipeline' to be BSON docs (or equivalent), but got primitive.D instead. Doc = [{from post} {localField translated_version} {foreignField _id} {pipeline [{$project [{slug 1}]}]} {as translated_version}]"
My code:
lookup_translated_post := bson.D{
{
Key: "$lookup", Value: bson.D{
{
Key: "from", Value: model_name,
},
{
Key: "localField", Value: "translated_version",
},
{
Key: "foreignField", Value: "_id",
},
{
Key: "pipeline", Value: bson.D{
{
Key: "$project", Value: bson.D{
{
Key: "slug", Value: 1,
},
},
},
},
},
{
Key: "as", Value: "translated_version",
},
},
},
}
Don’t understand what I’m doing wrong Already tried to get help from Mongo community, but got no answer