I am trying to find the syntax to delete a mongoDB record using PHP, but every example I find on internet only shows how to do it if the deletion criteria is one level...
So if I have a mongoDB record like this:
{
"_id" : ObjectId("50d69d6a1d26a8a0c1eaecf8"),
"name" : "John",
...other fields...
The I can delete it using the syntax:
$collection->remove(array('name' => 'John'));
This is fine, however my problem is that the key I need to lookup for deletion is one more level down.
So I have a record that looks like this:
{
"_id" : ObjectId("54f2aaa3452a235c049000029"),
"synthOrder" : {
"orderId" : "899422",
...other fields...
I want to delete records in which orderId is say, 899422. So what would my deletion line be like?
I tried:
$collection->remove(array('synthOrder' => array('orderId' => '899422')));
I feel it is a simple syntax issue, but I am not able to find any example online. I appreciate any pointers!