I am using this
function delete($col,$condition = array()){
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->delete($condition, ['limit' => 1]);
$manager = new MongoDB\Driver\Manager($this->mongo);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 1000);
$result = $manager->executeBulkWrite($this->db.'.'.$col, $bulk, $writeConcern);
var_dump($result);
}
And the code works and getting output like bellow
object(MongoDB\Driver\WriteResult)#30 (9) { ["nInserted"]=> int(0) ["nMatched"]=> int(0) ["nModified"]=> int(0) ["nRemoved"]=> int(0) ["nUpserted"]=> int(0) ["upsertedIds"]=> array(0) { } ["writeErrors"]=> array(0) { } ["writeConcernError"]=> NULL ["writeConcern"]=> array(4) { ["w"]=> string(8) "majority" ["wmajority"]=> bool(true) ["wtimeout"]=> int(1000) ["journal"]=> NULL } }
Now I can't convert the object to array. How to get the properties like "nRemoved" / "nUpdated" from the object?