1
I’m trying to make a query to return only bank 1 investments that are not savings. How do I do? I have tried several ways and it has not worked so far.
I followed the following query:
db.Bancos.find( { "investimentos": { $elemMatch: { bank: "banco1", productName: {$ne:"Poupanca"} } } } );
{
"_id": "5d3fc8c3914297c7b9a3a9e5",
"banco": "banco 1",
"investimentos": [{
"bank": "banco1",
"risk": "Conservador",
"expiryDate": "2021-10-04",
"tax": "1.02",
"discriminator": "investment",
"productName": "LCI"
},
{
"bank": "banco1",
"risk": "Conservador",
"expiryDate": "2020-06-24",
"tax": "0.75",
"discriminator": "investment",
"productName": "Fundo DI"
},
{
"bank": "banco1",
"risk": "Conservador",
"tax": "0.04",
"discriminator": "investment",
"id": "259ad8ac-57b7-4d33-8e75-46cf5c5c28e3",
"aniversary": "30",
"productName": "Poupanca"
}
}]
{
"_id": "5d3fcb4c914297c7b9a3a9e6",
"banco": "banco2",
"investimentos": [{
"bank": "banco2",
"risk": "Conservador",
"expiryDate": "2020-06-24",
"tax": "0.80",
"discriminator": "investment",
"id": "73db503f-c780-448c-a6a8-05d2837ff6ff",
"redemptionDate": "D+1",
"productName": "Fundo DI"
}
,
{
"bank": "banco2",
"risk": "Conservador",
"expiryDate": "2020-12-17",
"tax": "0.98",
"discriminator": "investment",
"id": "54e01515-dc7f-470f-8f00-8603c8f00686",
"productName": "LCA"
},
{
"bank": "banco2",
"risk": "Conservador",
"expiryDate": "2021-08-05",
"tax": "1.0",
"discriminator": "investment",
"id": "259ad8ac-57b7-4d33-8e75-46cf5c5c28e2",
"productName": "CDB"
}
}]
This makes it impossible to help. Create an example minimum, complete and verifiable. That is: provide at least how your query and Collection are structured.
– Murilo Sitonio
Okay, I’m better, sorry.
– Luan Carvalho