@furystack/core
Version:
Core FuryStack package
49 lines • 1.78 kB
TypeScript
import type { Constructable } from '@furystack/inject';
import { EventHub } from '@furystack/utils';
import type { CreateResult, FilterType, FindOptions, PartialResult, PhysicalStore } from './models/physical-store.js';
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> {
/**
*
* @param keys The keys to remove from the store
*/
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>;
private evaluateLike;
private filterInternal;
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>;
/**
* Creates an InMemoryStore that can be used for testing purposes.
* @param options Options for the In Memory Store
* @param options.primaryKey The name of the primary key field
* @param options.model The Entity Model
*/
constructor(options: {
/**
* The name of the Primary Key property
*/
primaryKey: TPrimaryKey;
/**
* The model constructor
*/
model: Constructable<T>;
});
}
//# sourceMappingURL=in-memory-store.d.ts.map