I need to get the total number of array elements that are present inside the products
array . So far i have tried using the $size=>$products
approach but since technically there are two arrays only the value i get is 2
but i want to count the inner elements as well so that the desired result comes out to be 3
.
I know i need to use $unwind
but i cant figure out the approach.
{
_id:2,
card_pay:3998,
count:4598,
orders:2,
products:[
[
{
product_id:{
$oid:"5c63d418ae1db123d8048276"
},
amount:2499,
quantity:1,
status:1
},
{
product_id:{
$oid:"5c46f7f329067970211471a0"
},
amount:200,
quantity:2,
status:1
}
],
[
{
product_id:{
$oid:"5c63d3afae1db123d8048273"
},
amount:1499,
quantity:1,
status:1
}
]
]
}
Aucun commentaire:
Enregistrer un commentaire