# 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.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
constructor |
void
|
<optional> |
No constructor parameters required; the superclass handles internal state. |
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.
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. |
The located or auto-created injectable instance; otherwise undefined if it cannot be resolved.
T
|
undefined