CountModel
Contract for models able to count the documents they manage.
A CountModel exposes a single CountModel::count() operation that
returns how many documents match the supplied options, without materializing
the documents themselves. It is the cheapest way to probe the size of a
collection or the cardinality of a filtered query.
Tags
Table of Contents
Methods
- count() : int
- Returns the number of documents matching the given options.
Methods
count()
Returns the number of documents matching the given options.
public
count([array<string|int, mixed> $init = [] ]) : int
Parameters
- $init : array<string|int, mixed> = []
-
Operation options driving the count, e.g. filtering conditions, bind variables (
binds) or a precompiled query. An empty array counts every document.
Tags
Return values
int —The number of matching documents (0 when none match).