Function combineHooks

  • Combines multiple hook objects into a single hook object.

    When multiple hooks are combined, they execute in order. For transformation hooks (onBefore*, onAfter*), each hook receives the result of the previous hook.

    Parameters

    Returns StorageHooks

    Combined hook object

    const loggingHooks: StorageHooks = {
    onBeforeQuery: async (ctx) => {
    console.log('Query:', ctx.statement);
    return ctx;
    }
    };

    const metricsHooks: StorageHooks = {
    onAfterQuery: async (ctx, result) => {
    metrics.record('query', Date.now() - ctx.startTime);
    return result;
    }
    };

    const combinedHooks = combineHooks(loggingHooks, metricsHooks);