MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / prepareMetadataContext

Function prepareMetadataContext

packages/decorators/src/utils.ts:107–127  ·  view source on GitHub ↗
(
  context:
    | ClassFieldDecoratorContext<T>
    | ClassGetterDecoratorContext<T>
    | ClassSetterDecoratorContext<T>
    | ClassAccessorDecoratorContext<T>
    | ClassMethodDecoratorContext<T>,
  kind?: ReferenceKind,
)

Source from the content-addressed store, hash-verified

105 * exist for some base entity.
106 */
107export function prepareMetadataContext<T>(
108 context:
109 | ClassFieldDecoratorContext<T>
110 | ClassGetterDecoratorContext<T>
111 | ClassSetterDecoratorContext<T>
112 | ClassAccessorDecoratorContext<T>
113 | ClassMethodDecoratorContext<T>,
114 kind?: ReferenceKind,
115): EntityMetadata<T> {
116 const meta = context.metadata as unknown as EntityMetadata<T>;
117
118 if (!Object.hasOwn(meta, 'properties')) {
119 meta.properties = { ...meta.properties };
120 }
121
122 if (kind) {
123 validateSingleDecorator(meta, context.name as string, kind);
124 }
125
126 return meta;
127}
128
129/**
130 * Uses some dark magic to get source path to caller where decorator is used.

Callers 9

createDecoratorFunction · 0.85
EmbeddedFunction · 0.85
ManyToManyFunction · 0.85
OneToManyFunction · 0.85
EnumFunction · 0.85
ManyToOneFunction · 0.85
PropertyFunction · 0.85
FormulaFunction · 0.85
OneToOneFunction · 0.85

Calls 1

validateSingleDecoratorFunction · 0.85

Tested by

no test coverage detected