0

I want to get a highest value for a specific column in mongodb using the php library provided by mongodb currently i am using the following code

`$filter = ['server' => 2];

$options = ['sort' => ['nativeId' => -1]];

$id = $collection->find($filter,$options);

$id->toArray()[0]`

the problem is the whole result loaded in $id object so if the database collection contains a 1 million record all data will be loaded i want to use the max option but i don't know how

the documentation of mongodb does not explain more about this max option

mabbas
  • 1
  • 1

0 Answers0