Skip to content

Commit

Permalink
feat(core): allow using second argument of @OneToOne as options
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Nov 5, 2022
1 parent 3575307 commit 115462d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/decorators/OneToOne.ts
Expand Up @@ -5,9 +5,11 @@ import type { AnyString, EntityName } from '../typings';

export function OneToOne<T, O>(
entity?: OneToOneOptions<T, O> | string | ((e?: any) => EntityName<T>),
mappedBy?: (string & keyof T) | ((e: T) => any),
mappedByOrOptions?: (string & keyof T) | ((e: T) => any) | Partial<OneToOneOptions<T, O>>,
options: Partial<OneToOneOptions<T, O>> = {},
) {
const mappedBy = typeof mappedByOrOptions === 'object' ? mappedByOrOptions.mappedBy : mappedByOrOptions;
options = typeof mappedByOrOptions === 'object' ? { ...mappedByOrOptions, ...options } : options;
return createOneToDecorator<T, O>(entity as string, mappedBy, options, ReferenceType.ONE_TO_ONE);
}

Expand Down

0 comments on commit 115462d

Please sign in to comment.