index<T extends Model> static method

Future<List<T>> index<T extends Model>()

Retrieves all records (ordered by id DESC).

Implementation

static Future<List<T>> index<T extends Model>() async {
  try {
    final constructor = _jsonConstructors[T];
    if (constructor == null) return [];
    final maps = await _database.query(_getTableName<T>(), orderBy: 'id DESC');
    return maps.map((map) => constructor(map) as T).toList();
  } catch (e) {
    print('SQLite index error: $e');
    return [];
  }
}