I am currently working on a product filtering logic for my project.
Within the Products model, I have implemented a search functionality to filter products based on query parameters. These parameters are stored in an array of settings (queryConditions) if any filtering is applied.
Shown below is an example of one of the objects present in the Products model:
{
"products": [
{
"_id": "6612fee192f83be6c8f1f14a",
"name": "Iphone 15",
"__t": "Phones",
"price": "105990",
"color": "Белый",
"memory": "128",
"screen": "2480 x 1080",
"fps": "240",
"sim": "eSim",
"preview": "3e26f117-e925-4303-adb5-930874e7ea21.png",
"images": [
"3db588ef-63f6-4596-8284-f02f4e465765.png",
"e9437348-eb56-4537-8c13-cbbb697bcc41.png"
],
"category": {
"_id": "6612b3c9a56d07ad6a21e332",
"name": "Телефоны",
"preview": "phones.png"
},
"type": "6612b4a9a56d07ad6a21e384",
"count": 1,
"createdAt": "2024-04-07T20:15:29.009Z",
"updatedAt": "2024-04-07T20:15:29.009Z",
"__v": 0
}
],
"count": 1
}
This setup involves complex filtering conditions as shown in the code snippet below:
(the filtering code remains unchanged)
An illustration of the Products Schema and Category Schema structure is provided in subsequent code blocks.
... (remaining content stays consistent)