findOrFail method

Future<T> findOrFail(
  1. dynamic id
)

Finds a model by primary key or throws if not found.

Implementation

Future<T> findOrFail(dynamic id) async {
  final model = await find(id);
  if (model == null) {
    throw StateError('$T with id $id not found');
  }
  return model;
}