readMany method

  1. @override
Future<List<Data>> readMany(
  1. List<Id> ids, [
  2. Map<String, dynamic>? params
])

Reads multiple resources at once.

Service implementations should override this to ensure data is fetched within a single round trip.

Implementation

@override
Future<List<Data>> readMany(List<Id> ids,
    [Map<String, dynamic>? params]) async {
  if (ids.isEmpty) {
    throw ArgumentError.value(ids, 'ids', 'cannot be empty');
  }

  var query = await queryCreator();
  var builder = _findBuilder(query, idField);

  try {
    (builder as dynamic).isIn(ids);
  } on NoSuchMethodError {
    throw UnsupportedError(
        '${builder.runtimeType} `$idField` has no `isIn` method, and therefore does not support `readMany`.');
  }

  await _applyQuery(query, params);
  return await query.get(executor);
}