readAllWhere method

Future<List<T>> readAllWhere({
  1. List<Constraint> where = const [],
  2. int? limit,
})

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>> readAllWhere(
    {List<Constraint> where = const [], int? limit}) async {
  final result = await executeQuery(getReadAllWhereQuery(
    entityName: _entityName,
    where: where,
    limit: limit,
  ));

  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;
}