Skip to content

Commit 3235940

Browse files
committed
Add options to countDocuments method
1 parent aebf049 commit 3235940

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function toMql(): array
346346
$aggregations = blank($this->aggregate['columns']) ? [] : $this->aggregate['columns'];
347347

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

351351
return ['countDocuments' => [$wheres, $options]];
352352
}

tests/QueryTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,13 @@ public function testDelete(): void
660660
User::limit(null)->delete();
661661
$this->assertEquals(0, User::count());
662662
}
663+
664+
public function testLimitCount(): void
665+
{
666+
$count = User::where('age', '>=', 20)->count();
667+
$this->assertEquals(7, $count);
668+
669+
$count = User::where('age', '>=', 20)->options(['limit' => 3])->count();
670+
$this->assertEquals(3, $count);
671+
}
663672
}

0 commit comments

Comments
 (0)