index<T extends Model> static method
Retrieves all records of type T.
Implementation
static Future<List<T>> index<T extends Model>() async {
final constructor = _jsonConstructors[T];
if (constructor == null) return [];
final file = File("$_dir/${_getTableName<T>()}.json");
if (!await file.exists()) return [];
try {
final content = await file.readAsString();
if (content.trim().isEmpty) return [];
final List<dynamic> jsonList = jsonDecode(content);
return jsonList.map((item) => constructor(item) as T).toList();
} catch (e, stack) {
print('Error reading table file: $e\n$stack');
return [];
}
}