findFirst method

T? findFirst()

Finds the first object matching this query.

Returns null if no object matches.

Note: if no QueryBuilder.order conditions are present, which object is the first one might be arbitrary (sometimes the one with the lowest ID, but never guaranteed to be).

Implementation

T? findFirst() {
  T? result;
  final errorWrapper = ObjectVisitorError();
  visitCallBack(Pointer<Uint8> data, int size) {
    try {
      result = _entity.objectFromData(_store, data, size);
    } catch (e) {
      errorWrapper.error = e;
    }
    return false; // we only want to visit the first element
  }

  visit(_ptr, visitCallBack);
  errorWrapper.throwIfError();
  return result;
}