Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit db771b1

Browse files
committed
PHPORM-50 Remove call to deprecated Collection::count for estimatedDocumentCount
https://www.mongodb.com/docs/php-library/current/reference/method/MongoDBCollection-count/ Not using countDocuments because it doesn't work with transactions.
1 parent 9d9c7c8 commit db771b1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
1010
- Throw an exception for unsupported `Query\Builder` methods [#9](https://github.com/GromNaN/laravel-mongodb-private/pull/9) by [@GromNaN](https://github.com/GromNaN).
1111
- Throw an exception when `Query\Builder::orderBy()` is used with invalid direction [#7](https://github.com/GromNaN/laravel-mongodb-private/pull/7) by [@GromNaN](https://github.com/GromNaN).
1212
- Throw an exception when `Query\Builder::push()` is used incorrectly [#5](https://github.com/GromNaN/laravel-mongodb-private/pull/5) by [@GromNaN](https://github.com/GromNaN).
13+
- Remove call to deprecated `Collection::count` for `countDocuments` [#18](https://github.com/GromNaN/laravel-mongodb-private/pull/18) by [@GromNaN](https://github.com/GromNaN).
1314

1415
## [3.9.2] - 2022-09-01
1516

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function toMql(): array
273273
$aggregations = blank($this->aggregate['columns']) ? [] : $this->aggregate['columns'];
274274

275275
if (in_array('*', $aggregations) && $function == 'count') {
276-
return ['count' => [$wheres, []]];
276+
return ['estimatedDocumentCount' => [$wheres, []]];
277277
} elseif ($function == 'count') {
278278
// Translate count into sum.
279279
$group['aggregate'] = ['$sum' => 1];
@@ -403,7 +403,7 @@ public function getFresh($columns = [], $returnLazy = false)
403403
$this->columns = [];
404404
}
405405

406-
$command = $this->toMql($columns);
406+
$command = $this->toMql();
407407
assert(count($command) >= 1, 'At least one method call is required to execute a query');
408408

409409
$result = $this->collection;

0 commit comments

Comments
 (0)