Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
* Remove custom `PasswordResetServiceProvider`, use the default `DatabaseTokenRepository` by @GromNaN in [#3124](https://github.com/mongodb/laravel-mongodb/pull/3124)
* Remove `Blueprint::background()` method by @GromNaN in [#3132](https://github.com/mongodb/laravel-mongodb/pull/3132)
* Replace `Collection` proxy class with Driver monitoring by @GromNaN in [#3137]((https://github.com/mongodb/laravel-mongodb/pull/3137)
* Support options in `count()` queries by @verduck in [#3142](https://github.com/mongodb/laravel-mongodb/pull/3142)

## [4.8.0] - 2024-08-27

Expand Down
2 changes: 1 addition & 1 deletion src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function toMql(): array
$aggregations = blank($this->aggregate['columns']) ? [] : $this->aggregate['columns'];

if (in_array('*', $aggregations) && $function === 'count') {
$options = $this->inheritConnectionOptions();
$options = $this->inheritConnectionOptions($this->options);

return ['countDocuments' => [$wheres, $options]];
}
Expand Down
9 changes: 9 additions & 0 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,13 @@ public function testDelete(): void
User::limit(null)->delete();
$this->assertEquals(0, User::count());
}

public function testLimitCount(): void
{
$count = User::where('age', '>=', 20)->count();
$this->assertEquals(7, $count);

$count = User::where('age', '>=', 20)->options(['limit' => 3])->count();
$this->assertEquals(3, $count);
}
}
Loading