toQuery method
Query
toQuery()
Implementation
Query<dynamic> toQuery() {
final isar = Isar.getInstance(instance)!;
// ignore: invalid_use_of_protected_member
final collection = isar.getCollectionByNameInternal(this.collection)!;
WhereClause? whereClause;
var whereSort = Sort.asc;
SortProperty? sortProperty;
if (this.sortProperty != null) {
if (this.sortProperty == collection.schema.idName) {
whereClause = const IdWhereClause.any();
whereSort = sortAsc == true ? Sort.asc : Sort.desc;
} else {
sortProperty = SortProperty(
property: this.sortProperty!,
sort: sortAsc == true ? Sort.asc : Sort.desc,
);
}
}
return collection.buildQuery(
whereClauses: [if (whereClause != null) whereClause],
whereSort: whereSort,
filter: filter,
offset: offset,
limit: limit,
sortBy: [if (sortProperty != null) sortProperty],
);
}