I have a collection with the following schema:
{
"id": "1",
"properties": [
{ "key": "key1", "value": "8" },
{ "key": "key2", "value": "5" }
]
},
{
"id": "2",
"properties": [
{ "key": "key1", "value": "2" },
{ "key": "key2", "value": "5" }
]
},
{
"id": "3",
"properties": [
{ "key": "key1", "value": "9" },
{ "key": "key2", "value": "9" }
]
},
{
"id": "4",
"properties": [
{ "key": "key1", "value": "6" },
{ "key": "key2", "value": "5" }
]
}
// so on...
Now I have an array of filters, for example, [{ "key": "key2", "value": "5" }, { "key": "key1", "value": "6" }]. I want my response to be the following because both objs with ids 1 and 2 have { "key": "key2", "value": "5" } in their properties field. And obj with id 4 because of { "key": "key1", "value": "6" }.
Because everything is so nested, what would be the best way to approach this?
{
"id": "1",
"properties": [
{ "key": "key1", "value": "8" },
{ "key": "key2", "value": "5" }
]
},
{
"id": "2",
"properties": [
{ "key": "key1", "value": "2" },
{ "key": "key2", "value": "5" }
]
},
{
"id": "4",
"properties": [
{ "key": "key1", "value": "6" },
{ "key": "key2", "value": "5" }
]
}