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

Function OneToMany

packages/decorators/src/es/OneToMany.ts:21–33  ·  view source on GitHub ↗
(
  entity: OneToManyOptions<Owner, Target> | string | ((e?: any) => EntityName<Target>),
  mappedBy?: (string & keyof Target) | ((e: Target) => any),
  options: Partial<OneToManyOptions<Owner, Target>> = {},
)

Source from the content-addressed store, hash-verified

19 options: OneToManyOptions<Owner, Target>,
20): (value: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) => void;
21export function OneToMany<Target extends object, Owner extends object>(
22 entity: OneToManyOptions<Owner, Target> | string | ((e?: any) => EntityName<Target>),
23 mappedBy?: (string & keyof Target) | ((e: Target) => any),
24 options: Partial<OneToManyOptions<Owner, Target>> = {},
25): (value: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) => void {
26 return function (value: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) {
27 const meta = prepareMetadataContext(context, ReferenceKind.ONE_TO_MANY);
28 options = processDecoratorParameters<OneToManyOptions<Owner, Target>>({ entity, mappedBy, options });
29 const property = { name: context.name, kind: ReferenceKind.ONE_TO_MANY } as EntityProperty<Owner>;
30 meta.properties[context.name as EntityKey<Owner>] ??= {} as any;
31 Utils.mergeConfig(meta.properties[context.name as EntityKey<Owner>], property, options);
32 };
33}

Callers 2

AuthorClass · 0.90
CClass · 0.90

Calls 3

prepareMetadataContextFunction · 0.85
mergeConfigMethod · 0.80

Tested by

no test coverage detected