interceptWith method

QueryExecutor interceptWith(
  1. QueryInterceptor interceptor, {
  2. bool sticky = true,
})

Returns a QueryExecutor that will use this executor internally, but with calls intercepted by the given interceptor.

This can be used to, for instance, write a custom statement logger or to retry failing statements automatically.

When sticky is enabled (the default), child executors (e.g. transactions) are also intercepted using the interceptor.

Implementation

QueryExecutor interceptWith(
  QueryInterceptor interceptor, {
  bool sticky = true,
}) {
  final $this = this;

  if ($this is TransactionExecutor) {
    return _InterceptedTransactionExecutor($this, interceptor, sticky);
  } else {
    return _InterceptedExecutor($this, interceptor, sticky);
  }
}