sorted method
Returns an iterable with this table's rows in this table by the given key
column by
.
Implementation
Iterable<E> sorted({required Symbol by, bool descending = false}) {
final symbol = by.name.split('.');
final type = symbol.first, key = symbol.last;
final ordering = descending ? 'DESC' : 'ASC';
if (type != (E).toString()) {
throw ArgumentError.value('#${by.name}', 'by', 'Type mismatch, found $type, expected ${(E).toString()}');
}
if (!keys.contains(key)) {
throw ArgumentError.value('#${by.name}', 'by', '\'$key\' does not match any persisting field in ${(E).toString()}');
}
return database.select('SELECT * FROM $tableName ORDER BY $key $ordering').map(deserialize);
}