I have in a collection stores , products and many prices (for store-products there are many prices) of the products in MongoDB I have to find out min price from a product in a store in the last 30 days with the help of go I have built the following aggregation pipeline
pipeline := []bson.M{
bson.D{
"$group", bson.D{
{
"_id", bson.D{
{
Key: "storeId",
Value: "$storeUd",
},
{
Key: "productId",
Value: "$productId",
},
},
},
minPrice : {
Key: "min",
Value: "$price",
},
},
} <---
}
But go compiler tell me in the line that I marked with an arrow (<---) there is a mistake
syntax error: unexpected newline in composite literal; possibly missing comma or }
I would like to calculate something like
select min(price)
from prices
group by storeId , productId
Please can you tell me what is wrong?
Thanks, Aurel
I added }, but what I get you can see in the attached picture - the next declaration (var ... ) is in red ....