-
Notifications
You must be signed in to change notification settings - Fork 265
Closed
Labels
Description
I have set a typeMap in the global client:
$connectionString = '...'; // omitted actual value
$db = 'mydb';
$collection = 'mycollection';
$uriOptions = [];
$driverOptions = ['typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array']];
$mongoDb = new \MongoDB\Client($connectionString, $uriOptions, $driverOptions);
Then when i call findOneAndUpdate
:
$mongoDb->selectDatabase($db)->selectCollection($collection)->findOneAndUpdate($criteria, $updates, $options);
I get back a stdClass
object at the root level. I was expecting an array. The old pecl/mongo driver used to return an array
and the typeMap is not being respected to allow me to get it back just like the old driver.
I appreciate and understand the move to BSONDocument and BSONArray and if this were a new project I would not be setting that typemap and taking advantage of the new BSON serialisation behaviours. However there is a fairly large codebase that is sitting on top of the old behaviour and relying on it and updating all that code to use the new BSON behaviour is unpractical.