API reference > @kontsedal/olas-entities > entitiesPlugin
entitiesPlugin() function
Build the entity-normalization plugin:
ts
createRoot(App, {
deps,
queries: queryEngine(),
plugins: [entitiesPlugin({ entities: [Post, User] })],
})
// in a controller
const entities = ctx.inject(Entities)
entities.update(Post, 'p1', { liked: true })Lifecycle: - On every cache write, the plugin walks the written data and finds every subtree value that a registered entity claims via idOf. It updates both the normalized store and the reverse index (entity-id → bindings). - On update, it reads the reverse index for the entity and writes the patch into every binding with host.queries.write, inside one batch so subscribers see one round of notifications. - Regular and infinite queries are both observed. The store is per root: each root the plugin is installed in gets its own.
Signature:
typescript
export declare function entitiesPlugin(options: EntitiesOptions): OlasPlugin;Parameters
Parameter | Type | Description |
|---|---|---|
options |
Returns: