count method
Future<int>
count(
- SearchCriteria criteria,
- DbPrincipal principal, {
- SearchPolicy? searchPolicy,
- RepositoryTransaction? transaction,
Searches entities according to criteria
and returns the
total count of entities fitting the constraints.
Implementations should filter the search results
limiting them to entities belonging to
the tenant of the principal
.
By default, this method will search
all entities in the collection owned by
the principal
, except when the
permission
parameter is given.
When the permission
parameter has a
non-empty argument and the user identified
by the principal
has that permission,
then all the entities in the collection
belonging to the tenant within the criteria
defined by the criteria
, regardless of
their owner within the tenant.
Implementation
@override
Future<int> count(
SearchCriteria criteria,
DbPrincipal principal, {
SearchPolicy? searchPolicy,
RepositoryTransaction? transaction,
}) async {
searchPolicy ??= this.searchPolicy;
var filters = _createFilters(criteria);
var baseQuery = filters.item1;
var parameters = filters.item2;
var count = await _getCount(
baseQuery,
parameters,
principal,
searchPolicy,
transaction: transaction,
);
return count;
}