Interface AdapterContext

Runtime context providing introspection into the current adapter.

This interface provides a high-level API for querying adapter capabilities, connection state, and performance without requiring manual capability flag checking.

const context = adapter.context;

// Simple boolean checks
if (context.supportsBatch) {
await adapter.batch(operations);
}

// Get detailed status
const status = context.getStatus();
console.log(`Healthy: ${status.healthy}, Queries: ${status.totalQueries}`);

// Get limitations
const limits = context.getLimitations();
console.log(`Max batch size: ${limits.maxBatchSize}`);
interface AdapterContext {
    adapter: StorageAdapter;
    kind: AdapterKind;
    capabilities: ReadonlySet<StorageCapability>;
    isOpen: boolean;
    supportsSync: boolean;
    supportsTransactions: boolean;
    supportsBatch: boolean;
    supportsPrepared: boolean;
    supportsStreaming: boolean;
    supportsWAL: boolean;
    supportsJSON: boolean;
    supportsArrays: boolean;
    supportsConcurrent: boolean;
    supportsPersistence: boolean;
    connectionInfo: ConnectionInfo;
    hasCapability(capability: StorageCapability): boolean;
    requiresCapability(capability: StorageCapability): void;
    getLimitations(): AdapterLimitations;
    getStatus(): AdapterStatus;
}

Properties

Reference to the underlying adapter

Adapter kind identifier

capabilities: ReadonlySet<StorageCapability>

Set of capabilities supported by this adapter

isOpen: boolean

Whether the adapter is currently open/connected

supportsSync: boolean

Whether the adapter supports synchronous operations

supportsTransactions: boolean

Whether the adapter supports ACID transactions

supportsBatch: boolean

Whether the adapter supports batch operations

supportsPrepared: boolean

Whether the adapter supports prepared statements

supportsStreaming: boolean

Whether the adapter supports streaming results

supportsWAL: boolean

Whether the adapter supports Write-Ahead Logging

supportsJSON: boolean

Whether the adapter supports native JSON operations

supportsArrays: boolean

Whether the adapter supports array data types

supportsConcurrent: boolean

Whether the adapter supports concurrent connections

supportsPersistence: boolean

Whether the adapter persists data across restarts

connectionInfo: ConnectionInfo

Information about the current connection

Methods

  • Check if a specific capability is supported.

    Parameters

    Returns boolean

    True if the capability is supported

    if (context.hasCapability('streaming')) {
    // Use streaming API
    }
  • Require a specific capability, throwing an error if not supported.

    Parameters

    Returns void

    If the capability is not supported

    context.requiresCapability('transactions');
    // Safe to use transactions now
    await adapter.transaction(async (trx) => { ... });