interface DocumentAdapter

Document adapter interface for NoSQL database operations.

Implement this interface to create drivers for specific document stores (e.g., Google Cloud Datastore, DynamoDB, Firestore). The Collection class wraps adapters with Task/Stream semantics.

For connection lifecycle management, use DocumentConnector which produces adapters.

Type Parameters

TDoc
TQuery
TKey

Methods

get(key: TKey): Promise<TDoc | null>

Fetches a single document by its primary key/reference.

put(
key: TKey,
doc: TDoc,
): Promise<void>

Upserts a document.

delete(key: TKey): Promise<void>

Deletes a document by its key.

query(query: TQuery): AsyncIterable<TDoc>

Executes a native query and yields results as an AsyncIterable. The adapter handles underlying pagination (e.g., Datastore's endCursor or DynamoDB's LastEvaluatedKey) internally.

putMany(entries: { key: TKey; doc: TDoc; }[]): Promise<void>

Batch writes multiple documents.

Usage

import { type DocumentAdapter } from ".";