sortBy<T> method
Null safety
- T propertyIdentifier(
- InstanceType x
- QuerySortOrder order
override
Configures this instance to sort its results by some property and order.
This method will have the database perform a sort by some property identified by propertyIdentifier
.
propertyIdentifier
must return a scalar property of InstanceType
that can be compared. The order
indicates the order the returned rows will be in. Multiple sortBys may be invoked on an instance;
the order in which they are added indicates sort precedence. Example:
var query = Query<Employee>()
..sortBy((e) => e.name, QuerySortOrder.ascending);
Implementation
@override
void sortBy<T>(
T Function(InstanceType x) propertyIdentifier,
QuerySortOrder order,
) {
final attribute = entity.identifyAttribute(propertyIdentifier);
sortDescriptors ??= <QuerySortDescriptor>[];
sortDescriptors!.add(QuerySortDescriptor(attribute.name, order));
}