import { ReferenceKind, Utils } from '@mikro-orm/core';
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
/** Defines a many-to-one relationship (TC39 decorator). */
export function ManyToOne(entity = {}, options = {}) {
  return function (_, context) {
    const meta = prepareMetadataContext(context, ReferenceKind.MANY_TO_ONE);
    options = processDecoratorParameters({ entity, options });
    const property = { name: context.name, kind: ReferenceKind.MANY_TO_ONE };
    meta.properties[context.name] = Utils.mergeConfig(meta.properties[context.name] ?? {}, property, options);
  };
}
