Class

InjectablesRegistry

InjectablesRegistry(constructoropt)

Constructor

# new InjectablesRegistry(constructoropt)

Provides an InjectableRegistry implementation that resolves repositories by model name or constructor. If a repository is not explicitly registered, it attempts to infer the correct repository using model metadata and the active or specified adapter flavour.

Registry for injectable repositories with auto-resolution.

sequenceDiagram participant C as Consumer participant R as InjectablesRegistry participant B as BaseRegistry participant M as Model participant A as Adapter participant RP as Repository C->>R: get(name, flavour?) activate R R->>B: super.get(name) alt Found in base registry B-->>R: injectable R-->>C: injectable else Not found R->>M: Model.get(name) alt Model found R->>A: resolve flavour (from arg/metadata/current) R->>RP: Repository.forModel(modelCtor, alias) alt Repository instance RP-->>R: repository instance R-->>C: repository instance else Repository ctor R->>A: Adapter.get(resolvedFlavour) or Adapter.current A-->>R: adapter instance R->>RP: new repoCtor(adapter, modelCtor) R-->>C: repository instance end else Model not found R-->>C: undefined end end
Parameters:
Name Type Attributes Description
constructor void <optional>

No constructor parameters required; the superclass handles internal state.

View Source repository/injectables.ts, line 9

Example
// Basic usage: retrieve a repository by model name
const registry = new InjectablesRegistry();
const userRepo = registry.get<UserRepository>('User');
// If UserRepository is registered, it will be returned. Otherwise, a repository will be created if a User model exists.

// Retrieve by constructor and specify adapter flavour
const repoByCtor = registry.get<UserRepository>(UserModel, 'ram');

// Retrieve by symbol (e.g., injectable token)
const token = Symbol.for('UserRepository');
const byToken = registry.get<UserRepository>(token);

Methods

# get(name, flavouropt) → {T|undefined}

Attempts to get an injectable from the base registry; if not found and the name refers to a known model, it resolves the appropriate repository using the specified flavour or model metadata, falling back to the current adapter when needed.

Retrieve an injectable with repository auto-resolution.

sequenceDiagram participant G as get(name, flavour?) participant BR as BaseRegistry participant M as Model participant A as Adapter participant RP as Repository G->>BR: super.get(name) alt Found BR-->>G: injectable else Not found G->>M: derive modelCtor from name alt modelCtor resolved G->>A: resolve flavour (arg | metadata | current) G->>RP: Repository.forModel(modelCtor, alias) alt returns instance RP-->>G: Repository instance else returns ctor G->>A: Adapter.get(flavour) | Adapter.current A-->>G: adapter instance G->>RP: new repoCtor(adapter, modelCtor) end else no modelCtor G-->>G: return undefined end end
Parameters:
Name Type Attributes Description
name string | symbol | Constructor.<T>

Token, model name, or constructor associated with the injectable or model.

flavour string <optional>

Optional adapter flavour (e.g., "ram"). If omitted, derives from metadata or current adapter.

View Source repository/injectables.ts, line 212

The located or auto-created injectable instance; otherwise undefined if it cannot be resolved.

T | undefined