findAll method

List<Object>? findAll()

Implementation

List<Object>? findAll() {
  if (isClosed) {
    return null;
  }

  final boxes = <Object>[];

  _execute((functions, transaction, database) {
    final Pointer<Pointer<MDB_cursor>> cursor = ffi.calloc();

    ErrorHandler(
      functions.mdbCursorOpen(transaction, database.value, cursor),
    );

    final Pointer<MDB_val> key = ffi.calloc();
    final Pointer<MDB_val> value = ffi.calloc();

    if (functions.mdbCursorGet(cursor.value, key, value, OP_MDB_FIRST) == 0) {
      boxes.add(_localize(value));

      while (functions.mdbCursorGet(cursor.value, key, value, OP_MDB_NEXT) ==
          0) {
        boxes.add(_localize(value));
      }
    }

    functions.mdbCursorClose(cursor.value);
  }, isReadOnly: true);

  return boxes;
}