findFirst method

T? findFirst()

Finds the first object matching the query. Returns null if there are no results. Note: offset and limit are respected, if set.

Implementation

T? findFirst() {
  T? result;
  Object? error;
  final visitor = dataVisitor((Pointer<Uint8> data, int size) {
    try {
      result = _entity.objectFromFB(
          _store, InternalStoreAccess.reader(_store).access(data, size));
    } catch (e) {
      error = e;
    }
    return false; // we only want to visit the first element
  });
  checkObx(C.query_visit(_ptr, visitor, nullptr));
  if (error != null) throw error!;
  reachabilityFence(this);
  return result;
}