I have data in the form of array of objects, Objects contain review and its key value pair and it has reviewDetail . Following is the data
[
{
"review": {
"reviewDetail": {
"title": "review 2",
"description": "this is description",
"file": [
"1659414826665-cropped-cropped-logo-e1620197043895-2.png.png"
],
"viewed": 0,
"isDeleted": true,
"_id": "62e8a92a0c6e7159a7b934d8",
"createdAt": "2022-08-02T04:33:46.677Z",
"updatedAt": "2022-08-02T04:37:28.213Z"
}
}
},
{
"review": {
"reviewDetail": {
"title": "review 1",
"description": "this is description of review",
"file": [
"1659414880490-cropped-cropped-logo-e1620197043895-2.png.png"
],
"viewed": 0,
"isDeleted": true,
"_id": "62e8a9600c6e7159a7b934df",
"createdAt": "2022-08-02T04:34:40.499Z",
"updatedAt": "2022-08-06T12:44:04.633Z"
}
}
},
{
"review": {
"reviewDetail": {
"title": "review 1",
"description": "this is description of review",
"file": [],
"viewed": 0,
"isDeleted": true,
"_id": "62ee5e76e9934990d6911e21",
"createdAt": "2022-08-06T12:28:38.457Z",
"updatedAt": "2022-08-06T13:24:03.074Z"
}
}
}
]
i want to extract reviewDetails in the array : following is the desired result
[
{
"title": "review 2",
"description": "this is description",
"file": [
"1659414826665-cropped-cropped-logo-e1620197043895-2.png.png"
],
"viewed": 0,
"isDeleted": true,
"_id": "62e8a92a0c6e7159a7b934d8",
"createdAt": "2022-08-02T04:33:46.677Z",
"updatedAt": "2022-08-02T04:37:28.213Z"
},
{
"title": "review 1",
"description": "this is description of review",
"file": [
"1659414880490-cropped-cropped-logo-e1620197043895-2.png.png"
],
"viewed": 0,
"isDeleted": true,
"_id": "62e8a9600c6e7159a7b934df",
"createdAt": "2022-08-02T04:34:40.499Z",
"updatedAt": "2022-08-06T12:44:04.633Z"
},
{
"title": "review 1",
"description": "this is description of review",
"file": [],
"viewed": 0,
"isDeleted": true,
"_id": "62ee5e76e9934990d6911e21",
"createdAt": "2022-08-06T12:28:38.457Z",
"updatedAt": "2022-08-06T13:24:03.074Z"
}
]
I tried to extract in particular pattern using Javascript in node js but needed using aggregation pipeline
projectfor this