Skip to content

API reference > @kontsedal/olas-entities > EntityStore

EntityStore type ​

One root's normalized entity store — the service entitiesPlugin provides. Reach it through the Entities scope: ctx.inject(Entities) in a controller, root.inject(Entities) outside one.

Per-entity ops are typed by the EntityDef<T> you pass in — signal(Post, id) returns ReadSignal<Post | undefined>, not ReadSignal<unknown>.

Signature:

typescript
export type EntityStore = {
  signal<T>(entity: EntityDef<T>, id: string): ReadSignal<T | undefined>;
  get<T>(entity: EntityDef<T>, id: string): T | undefined;
  upsert<T>(entity: EntityDef<T>, value: T): void;
  update<T extends object>(entity: EntityDef<T>, id: string, patch: Partial<T> | ((prev: T) => T), options?: {
    merge?: 'shallow' | 'deep';
  }): void;
  remove<T>(entity: EntityDef<T>, id: string): void;
  entries<T>(entity: EntityDef<T>): ReadonlyMap<string, T>;
  bindings<T>(entity: EntityDef<T>, id: string): ReadonlyArray<EntityBinding>;
  list<T>(entity: EntityDef<T>, options?: {
    filter?: (value: T) => boolean;
  }): ReadSignal<T[]>;
};

References: EntityDef, ReadSignal, EntityBinding

Released under the MIT License.