findOrFail method

Future<T> findOrFail(
  1. dynamic pkValue, {
  2. List<String> include = const [],
})

Find a record by primary key (id) or throw if not found.

Implementation

Future<T> findOrFail(dynamic pkValue, {List<String> include = const []}) async
{
  final result = await find(pkValue, include: include);

  if (result == null) {
    throw Exception("$table: record with primary key '$pkValue' not found");
  }

  return result;
}