Interface OperationContext

Base context for all operations.

Provides common information available to all hooks.

interface OperationContext {
    operationId: string;
    operation:
        | "get"
        | "all"
        | "exec"
        | "run"
        | "batch"
        | "transaction";
    startTime: number;
    adapterKind: string;
    metadata?: Record<string, unknown>;
}

Hierarchy (view full)

Properties

operationId: string

Unique identifier for this operation (UUID v4).

Use for correlation in logs and traces.

operation:
    | "get"
    | "all"
    | "exec"
    | "run"
    | "batch"
    | "transaction"

Operation type being performed.

startTime: number

Timestamp when operation started (ms since epoch).

adapterKind: string

Adapter kind (e.g., 'better-sqlite3', 'indexeddb', 'postgres').

metadata?: Record<string, unknown>

Custom metadata attached to this operation.

Hooks can read and modify this to pass data between hooks or to the calling code.

const results = await db.all(
'SELECT * FROM users WHERE id = ?',
[userId],
{ metadata: { skipCache: true, auditLevel: 'high' } }
);