readAll method

Future<List<T>> readAll()

Gets and executes a read Query to fetch an entity of Type T with the given id

Throws QueryFailedException if the query was not successful

Implementation

Future<List<T>> readAll() async {
  final result = await executeQuery(getReadAllQuery(entityName: _entityName));

  if (result.wasNotSuccessful) {
    throw QueryFailedException(result);
  }

  final elems = <T>[];
  for (final json in result.payload.values) {
    try {
      final elem = serializer.deserialize(Map<String, dynamic>.from(json));
      elems.add(elem);
      // ignore: avoid_catches_without_on_clauses
    } catch (_) {
      continue;
    }
  }

  return elems;
}