I have a collection with documents are like this:
{
"date" : 20200817,
"items" : [
{
"name" : "item1", "values" : ["val1", "val2", "val3"], "values2" : ["val21", "val22", "val23"]
},
{
"name" : "item2", "values" : ["val1", "val4"]
},
{
"name" : "item3", "values" : ["val1", "val3"], "values2" : ["val31", "val33"]
}
]
}
I want to get values and values2 from items that name is item3 like this
{"values" : ["val1", "val3"], "values2" : ["val31", "val33"]}
I have this query :
db.test.find(
{'items.name': 'item3'}, {'items.$.values': 1, 'items.$.values2': 1})
but i get this error
Cannot specify more than one positional proj. per query.
Where is my query wrong?
What can I do?
Thanks
aggregate()