Description
It seems like you should be able to use a bson.A to hold several bson.D or bson.M documents to create an aggregation pipeline. But when I try I get the error "cannot transform type primitive.A to a *bsonx.Document".
Example:
pipeline := bson.A{
|
bson.M{"$match": bson.M{"userID": userID}},
|
bson.M{"$sort": bson.M{"date": -1}},
|
bson.M{"$limit": defaultLimit},
|
// other steps
|
}
|
_, err := collection.Aggregate(context.Background(), pipeline)
|
err.Error() == "cannot transform type primitive.A to a *bsonx.Document"
|