discard method

Future<void> discard()

Discards a leased connection after its state can no longer be recovered.

Only a borrowed session or transaction view can be discarded. The view becomes unusable immediately; this does not prove a submitted write rolled back and does not close an otherwise usable root driver or pool.

Implementation

Future<void> discard() async {
  final connection = _connection;
  if (connection == null) {
    throw const OrmException(
      'SESSION.REQUIRED',
      'Discard requires a leased session.',
    );
  }
  _active = false;
  await connection.invalidate();
}