UNPKG

@mikro-orm/core

Version:

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.

31 lines (30 loc) 2.62 kB
import type { ReferenceOptions } from './Property'; import { type DeferMode } from '../enums'; import type { AnyEntity, AnyString, EntityName } from '../typings'; export declare function ManyToOne<T extends object, O>(entity?: ManyToOneOptions<T, O> | string | ((e?: any) => EntityName<T>), options?: Partial<ManyToOneOptions<T, O>>): (target: AnyEntity, propertyName: string) => any; export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner, Target> { /** Point to the inverse side property name. */ inversedBy?: (string & keyof Target) | ((e: Target) => any); /** Wrap the entity in {@apilink Reference} wrapper. */ ref?: boolean; /** Use this relation as a primary key. */ primary?: boolean; /** Map this relation to the primary key value instead of an entity. */ mapToPk?: boolean; /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */ joinColumn?: string; /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */ joinColumns?: string[]; /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */ ownColumns?: string[]; /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */ referenceColumnName?: string; /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */ referencedColumnNames?: string[]; /** What to do when the target entity gets deleted. */ deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString; /** What to do when the reference to the target entity gets updated. */ updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString; /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */ deferMode?: DeferMode | `${DeferMode}`; }