Мне нужно отфильтровать несколько вложенных объектов массива, используя несколько вложенных объектов, используя агрегат в узле mongoose js.Я упомянул примеры данных записей из объектов коллекции и мультифильтрации.
Здесь необходимо фильтровать записи на основе данных запроса на фильтрацию, а "isDefault" должно быть "true"
Примеры записей сбора
[
{
"_id": "5d710f9950b94f237f04407b",
"productfilter": [
{
"_id": "5d8d29ae014da910c0de0799",
"specTitle": "Color",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de079d",
"specLabel": "Rose Gold",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-rose-gold-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de079c",
"specLabel": "Black",
"isDefault": "true",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-black-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de079b",
"specLabel": "Blue",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-blue-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de079a",
"specLabel": "Red",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-red-6gb-64gb-redmi-note-6-pro"
}
]
},
{
"_id": "5d8d29ae014da910c0de0796",
"specTitle": "RAM",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de0798",
"specLabel": "4GB",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-black-4gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de0797",
"specLabel": "6GB",
"isDefault": "true",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-black-6gb-64gb-redmi-note-6-pro"
}
]
},
{
"_id": "5d8d29ae014da910c0de0794",
"specTitle": "Storage",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de0795",
"specLabel": "64GB",
"isDefault": "true",
"specContent": ""
}
]
}
]
},
{
"_id": "5d710fe050b94f237f04407e",
"productfilter": [
{
"_id": "5d8d29ae014da910c0de07a3",
"specTitle": "Color",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de07a7",
"specLabel": "Rose Gold",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-rose-gold-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de07a6",
"specLabel": "Black",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-black-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de07a5",
"specLabel": "Blue",
"isDefault": "true",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-blue-6gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de07a4",
"specLabel": "Red",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-red-6gb-64gb-redmi-note-6-pro"
}
]
},
{
"_id": "5d8d29ae014da910c0de07a0",
"specTitle": "RAM",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de07a2",
"specLabel": "4GB",
"isDefault": "false",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-blue-4gb-64gb-redmi-note-6-pro"
},
{
"_id": "5d8d29ae014da910c0de07a1",
"specLabel": "6GB",
"isDefault": "true",
"specContent": "mobiles-accessories-mobiles-redmi-redmi-redmi-note-6-pro-blue-6gb-64gb-redmi-note-6-pro"
}
]
},
{
"_id": "5d8d29ae014da910c0de079e",
"specTitle": "Storage",
"attributeOptions": [
{
"_id": "5d8d29ae014da910c0de079f",
"specLabel": "64GB",
"isDefault": "true",
"specContent": ""
}
]
}
]
}
]
Выборка выбранных данных запроса из списков параметров фильтра на страницах просмотра списка продуктов для фильтрации над записями
{
"filter": {
"genericFilter": [
{
"specTitle": "Color",
"specLabel": [
"Blue",
"Gold",
"Rose Gold"
]
},
{
"specTitle": "RAM",
"specLabel": [
"6GB",
"8GB"
]
},
{
"specTitle": "Storage",
"specLabel": [
"64GB",
"256GB"
]
}
]
}
}