In-memory implementation of IDatabaseAdapter.
Stores entities in plain Map structures, supporting basic CRUD,
filtering, sorting, pagination, and transaction semantics.
transactionIsolationLevels: readonly TransactionIsolationLevel[]
Portable isolation levels this adapter can honestly provide.
beginTransaction(options?: TransactionOptions): Promise<IAdapterTransaction>
Begin a transaction, returning a handle that can open transaction-scoped data sources as well as commit and roll back.
connect(): Promise<void>
countEntities(): Promise<number>
Count entities matching a filter.
createDataSource(entity: string,primaryKey?: string | readonly string[]): DataSource
Open a non-transactional data source for the named entity.
deleteEntity(entity: string,id: EntityKey): Promise<boolean>
Delete an entity by primary key.
disconnect(): Promise<void>
findEntityById(entity: string,id: EntityKey): Promise<Record<string, unknown> | null>
Find a single entity by its primary key value.
findPageInternal(): Promise<PageResult>
Core findPage implementation shared between the non-transactional data
source and the transaction overlay. The getRecords thunk lets the two
callers — the committed store and the per-tx overlay — each supply their
visible row set without duplicating the cursor-handling logic.
Pipeline:
- Decode the incoming cursor. When absent, the walk starts at page one. When malformed, reject by name.
- When present, verify the sort fingerprint so a cross-sort cursor is refused rather than served a silently wrong page.
- Build the portable keyset predicate with
keysetPredicate, conjoin it with the caller's own filter (when present), and applywhere/filter/orderByin the same order asfindAll. - Fetch
limit + 1rows (the one-extra-row probe): if more thanlimitare returned there IS a next page and the last returned row yields the next cursor; otherwise the page is terminal andnextCursorisnull. - When a projection is active, the key columns are added to the internal select so they participate in the probe and are available for cursor minting; they are stripped from the returned rows so the caller's projection is what comes back — plan §8 risk.
decoded.orderedValues carries the value of EVERY ordered field (in
orderBy order) from the last row of the previous page — not just key
column values. This is what keysetPredicate indexes by
position to build the "row after this one" comparison.
getStore(entity: string,primaryKey?: string | readonly string[]): EntityStore
Returns the internal store for an entity, creating it lazily.
insertEntity(entity: string,data: Partial<Record<string, unknown>>): Promise<Record<string, unknown>>
Insert a new entity. Generates key values if absent.
isReady(): boolean
queryEntities(entity: string,query: NormalizedQuery): Promise<Record<string, unknown>[]>
Query entities with full filtering, sorting, and pagination.
rawQuery<T>(_sql: string,_params?: unknown[]): Promise<T[]>
Execute a raw query in the backend's own dialect.
updateEntity(): Promise<Record<string, unknown>>
Update an existing entity by primary key, merging fields.