searchWithCount method
Future<SearchResult>
searchWithCount(
- SearchCriteria criteria,
- DbPrincipal principal, {
- SearchPolicy? searchPolicy,
- RepositoryTransaction? transaction,
Searches entities according to criteria
,
returning a page of entities and the count
of total entities that fit the given 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<SearchResult> searchWithCount(
SearchCriteria criteria,
DbPrincipal principal, {
SearchPolicy? searchPolicy,
RepositoryTransaction? transaction,
}) async {
searchPolicy ??= this.searchPolicy;
var filters = _createFilters(criteria);
var filterQuery = filters.item1;
var parameters = filters.item2;
var count = await (_getCount(
filterQuery,
{...parameters},
principal,
searchPolicy,
transaction: transaction,
));
var page = _createPage(
filterQuery,
criteria,
parameters,
principal,
searchPolicy,
transaction: transaction,
);
var ret = SearchResult(page, count);
return ret;
}