lundi 5 avril 2021

PHP MongoDB Cursor count is no longer working

I was using "jenssegers/mongodb": "2.1" and switched to "jenssegers/mongodb": "3.0.x" while upgrading from Laravel5.0 to Laravel 5.1 with php 5.6.x

I modified my codes for the upgraded version, but I'm no longer able to get the results count as used to before with this code:

$results = DB::connection($connection)
      ->collection("listing")
      ->timeout(-1)
      ->raw(function ($collection) use ($filters, $cols) {
          return $collection->find($filters, [
            'projection' => $cols
          ]);
      });
$count = $results->count();

How could I get now the count directly for the results returned?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire