@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
38 lines (37 loc) • 2.44 kB
TypeScript
import { type Dictionary, EntityMetadata, type EntityName } from '../typings.js';
import type { EntityManager } from '../EntityManager.js';
/** Registry that stores and provides access to entity metadata by class, name, or id. */
export declare class MetadataStorage {
#private;
static readonly PATH_SYMBOL: unique symbol;
constructor(metadata?: Dictionary<EntityMetadata>);
/** Returns the global metadata dictionary, or a specific entry by entity name and path. */
static getMetadata(): Dictionary<EntityMetadata>;
static getMetadata<T = any>(entity: string, path: string): EntityMetadata<T>;
/** Checks whether an entity with the given class name exists in the global metadata. */
static isKnownEntity(name: string): boolean;
/** Clears all entries from the global metadata registry. */
static clear(): void;
/** Returns the map of all registered entity metadata. */
getAll(): Map<EntityName, EntityMetadata>;
/** Returns metadata for the given entity, optionally initializing it if not found. */
get<T = any>(entityName: EntityName<T>, init?: boolean): EntityMetadata<T>;
/** Finds metadata for the given entity, returning undefined if not registered. */
find<T = any>(entityName: EntityName<T>): EntityMetadata<T> | undefined;
/** Checks whether metadata exists for the given entity. */
has<T>(entityName: EntityName<T>): boolean;
/** Registers metadata for the given entity. */
set<T>(entityName: EntityName<T>, meta: EntityMetadata): EntityMetadata;
/** Removes metadata for the given entity from all internal maps. */
reset<T>(entityName: EntityName<T>): void;
/** Decorates all entity prototypes with helper methods (e.g. init, toJSON). */
decorate(em: EntityManager): void;
[Symbol.iterator](): IterableIterator<EntityMetadata>;
/** Returns metadata by its internal numeric id. */
getById<T>(id: number): EntityMetadata<T>;
/** Returns metadata by class name, optionally throwing if not found. */
getByClassName<T = any, V extends boolean = true>(className: string, validate?: V): V extends true ? EntityMetadata<T> : EntityMetadata<T> | undefined;
/** Returns metadata by unique name, optionally throwing if not found. */
getByUniqueName<T = any, V extends boolean = true>(uniqueName: string, validate?: V): V extends true ? EntityMetadata<T> : EntityMetadata<T> | undefined;
private validate;
}