getAllSorted<T> method

Future<List<T>?> getAllSorted<T>(
  1. Object tableEntityInstance,
  2. String afterWhere
)

Returns every object of type T matching afterWhere, or null when no row matches.

Throws DatabaseException if the entity table does not exist.

Implementation

Future<List<T>?> getAllSorted<T>(
  Object tableEntityInstance,
  String afterWhere,
) async {
  final List<Map<String, Object?>> rows = await (await db).transaction(
    (txn) => txn.rawQuery(
      'SELECT * FROM ${T.toString()} WHERE ${_sanitizeWhere(afterWhere)}',
    ),
  );
  if (rows.isEmpty) return null;
  return rows
      .map((Map<String, Object?> row) =>
          (tableEntityInstance as dynamic).fromMap(row) as T)
      .toList();
}