I have this mongo structure in ehich i would like to check 3 values that are _id
, product_type_id
and condition_id
and the array in which all these condition match it's status should change from 0 to 1.
the following is my mongo data
{
"_id" : ObjectId("5b17b991c440782b5a218cd1"),
"product" : [
{
"id" : ObjectId("5b87d2ef40c1c45f88222093"),
"product_type_id" : ObjectId("5ae8348b7ae0d9538e45ab46"),
"condition_id" : [
{
"_id" : ObjectId("5ae978187ff1706f3b7dc47c"),
"status" : 1,
"date_added" : "2018-08-30-11-20-15"
}
],
"shipping_cost" : 100,
"date_added" : "2018-08-30-11-20-15",
"date_status_change" : "2018-08-30-11-20-15",
"status" : 0
},
{
...
},
{
...
}
]
}
So far i have tried this , but it's not working
[
"_id"=>$merchant_id,
"product" =>
[
'$elemMatch' =>
[
'product_type_id' => $product_type_id,
'condition_id' =>
[
'$elemMatch' =>
[
'_id' => $condition_id,
]
]
]
],
'$set' =>
[
'product.$.condition_id.$.status' => 1,
]
]