UNPKG

@furystack/core

Version:
37 lines 1.56 kB
import { EventHub } from '@furystack/utils'; import type { Constructable } from './models/constructable.js'; import type { CreateResult, FilterType, FindOptions, PartialResult, PhysicalStore } from './models/physical-store.js'; /** * In-memory {@link PhysicalStore} backed by a `Map`. Intended for tests, dev * fixtures and small reference datasets — entries are lost on process exit. * Production deployments should bind a real adapter (filesystem, MongoDB, * Sequelize, Redis) via `defineXxxStore`. */ export declare class InMemoryStore<T, TPrimaryKey extends keyof T> extends EventHub<{ onEntityAdded: { entity: T; }; onEntityUpdated: { id: T[TPrimaryKey]; change: Partial<T>; }; onEntityRemoved: { key: T[TPrimaryKey]; }; }> implements PhysicalStore<T, TPrimaryKey, T> { remove(...keys: Array<T[TPrimaryKey]>): Promise<void>; add(...entries: T[]): Promise<CreateResult<T>>; cache: Map<T[TPrimaryKey], T>; get: (key: T[TPrimaryKey], select?: Array<keyof T>) => Promise<Awaited<T> | undefined>; find<TFields extends Array<keyof T>>(searchOptions: FindOptions<T, TFields>): Promise<PartialResult<T, TFields>[]>; count(filter?: FilterType<T>): Promise<number>; update(id: T[TPrimaryKey], data: T): Promise<void>; [Symbol.dispose](): void; readonly primaryKey: TPrimaryKey; readonly model: Constructable<T>; constructor(options: { primaryKey: TPrimaryKey; model: Constructable<T>; }); } //# sourceMappingURL=in-memory-store.d.ts.map