Get one document - findOne

suggest change

Example for searching just one user with a specific id, you should do:

$options = ['limit' => 1];
$filter = ['_id' => new \MongoDB\BSON\ObjectID('578ff7c3648c940e008b457a')];
$query = new \MongoDB\Driver\Query($filter, $options);

$cursor = $manager->executeQuery('database_name.collection_name', $query);
$cursorArray = $cursor->toArray();
if(isset($cursorArray[0])) {
    var_dump($cursorArray[0]);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents