Function filterHooks

  • Creates a hook that only runs for specific operations.

    Parameters

    • operations: (
          | "get"
          | "all"
          | "exec"
          | "run"
          | "batch"
          | "transaction")[]

      Operations to filter for

    • hooks: StorageHooks

      Hooks to apply

    Returns StorageHooks

    Filtered hooks

    const writeOnlyHooks = filterHooks(['run', 'batch'], {
    onBeforeWrite: async (ctx) => {
    console.log('Write:', ctx.statement);
    return ctx;
    }
    });