I am trying to retrieve one element from a mongo collection, the one with the greatest _id field. I know this can be done by querying:
db.collection.find().s
with PHP driver (mongodb) using findOne()
findOne()
$filter=[]; $options = ['sort' => ['_id' => -1]]; // -1 is for DESC $result = $collection->findOne(filter, $options); $maxAge = $result['age']