From 115462db343276fa3ae4ddcd68f8e27c2647b737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Sat, 5 Nov 2022 12:53:23 +0100 Subject: [PATCH] feat(core): allow using second argument of `@OneToOne` as options --- packages/core/src/decorators/OneToOne.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/decorators/OneToOne.ts b/packages/core/src/decorators/OneToOne.ts index 7b1bf1b79bb6..cee0562c2066 100644 --- a/packages/core/src/decorators/OneToOne.ts +++ b/packages/core/src/decorators/OneToOne.ts @@ -5,9 +5,11 @@ import type { AnyString, EntityName } from '../typings'; export function OneToOne( entity?: OneToOneOptions | string | ((e?: any) => EntityName), - mappedBy?: (string & keyof T) | ((e: T) => any), + mappedByOrOptions?: (string & keyof T) | ((e: T) => any) | Partial>, options: Partial> = {}, ) { + const mappedBy = typeof mappedByOrOptions === 'object' ? mappedByOrOptions.mappedBy : mappedByOrOptions; + options = typeof mappedByOrOptions === 'object' ? { ...mappedByOrOptions, ...options } : options; return createOneToDecorator(entity as string, mappedBy, options, ReferenceType.ONE_TO_ONE); }