Skip to main content
Version: 6.4

OneToManyOptions <Owner, Target>

Hierarchy

Index

Properties

optionalinheritedautoincrement

autoincrement?: boolean

Explicitly specify the auto increment of the primary key.

optionalinheritedcascade

cascade?: Cascade[]

Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see cascading).

optionalinheritedcheck

check?: string | CheckCallback<Owner>

Specify column with check constraints. (Postgres driver only)

@see

optionalinheritedcolumnType

columnType?: AnyString | ColumnType

Specify exact database column type for Generator. (SQL only)

optionalinheritedcomment

comment?: string

Specify comment of column for Generator. (SQL only)

optionalinheritedconcurrencyCheck

concurrencyCheck?: boolean

Set to true to enable Locking via concurrency fields.

optionalinheritedcustomOrder

customOrder?: string[] | number[] | boolean[]

Specify a custom order based on the values. (SQL only)

optionalinheriteddefault

default?: null | string | number | boolean | string[] | number[]

Specify default column value for Generator. This is a runtime value, assignable to the entity property. (SQL only)

optionalinheriteddefaultRaw

defaultRaw?: string

Specify SQL functions for Generator. (SQL only) Since v4 you should use defaultRaw for SQL functions. e.g. now()

optionalinheritedeager

eager?: boolean

Always load the relationship. Discouraged for use with to-many relations for performance reasons.

optionalinheritedentity

entity?: string | () => EntityName<Target>

Set target entity type.

optionalinheritedextra

extra?: string

mysql only

optionalinheritedfieldName

fieldName?: string

Specify database column name for this property.

@see

optionalinheritedfieldNames

fieldNames?: string[]

Specify database column names for this property. Same as fieldName but for composite FKs.

@see

optionalinheritedformula

formula?: string | (alias: string) => string

Set to map some SQL snippet for the entity.

@see

optionalinheritedgenerated

generated?: string | GeneratedColumnCallback<Owner>

For generated columns. This will be appended to the column type after the generated always clause.

optionalinheritedgetter

getter?: boolean

Set true to define the properties as getter. (virtual)

@example
@Property({ getter: true })
get fullName() {
return this.firstName + this.lastName;
}

optionalinheritedgetterName

getterName?: keyof Owner

When defining a property over a method (not a getter, a regular function), you can use this option to point to the method name.

@example
@Property({ getter: true })
getFullName() {
return this.firstName + this.lastName;
}

optionalinheritedgroups

groups?: string[]

Specify serialization groups for serialize() calls. If a property does not specify any group, it will be included, otherwise only properties with a matching group are included.

optionalinheritedhidden

hidden?: boolean

Set to true to omit the property when Serializing.

optionalinheritedhydrate

hydrate?: boolean

Set false to disable hydration of this property. Useful for persisted getters.

optionalinheritedignoreSchemaChanges

ignoreSchemaChanges?: (type | extra | default)[]

Set to avoid a perpetual diff from the Generator when columns are generated.

@see

optionalinheritedindex

index?: string | boolean

Explicitly specify index on a property.

optionalinverseJoinColumn

inverseJoinColumn?: string

Override the default database column name on the inverse side (see Naming Strategy). This option is only for simple properties represented by a single column.

optionalinverseJoinColumns

inverseJoinColumns?: string[]

Override the default database column name on the inverse side (see Naming Strategy). This option is suitable for composite keys, where one property is represented by multiple columns.

optionaljoinColumn

joinColumn?: string

Override the default database column name on the owning side (see Naming Strategy). This option is only for simple properties represented by a single column.

optionaljoinColumns

joinColumns?: string[]

Override the default database column name on the owning side (see Naming Strategy). This option is suitable for composite keys, where one property is represented by multiple columns.

optionalinheritedlazy

lazy?: boolean

Set to omit the property from the select clause for lazy loading.

@see

optionalinheritedlength

length?: number

Set length of database column, used for datetime/timestamp/varchar column types for Generator. (SQL only)

mappedBy

mappedBy: (string & keyof Target) | (e: Target) => any

Point to the owning side property name.

optionalinheritedname

name?: string

Alias for fieldName.

optionalinheritednullable

nullable?: boolean

Set column as nullable for Generator.

optionalinheritedonCreate

onCreate?: (entity: Owner, em: EntityManager<IDatabaseDriver<Connection>>) => any

Automatically set the property value when entity gets created, executed during flush operation.


Type declaration

optionalinheritedonUpdate

onUpdate?: (entity: Owner, em: EntityManager<IDatabaseDriver<Connection>>) => any

Automatically update the property value every time entity gets updated, executed during flush operation.


Type declaration

optionalorderBy

orderBy?: QueryOrderMap<Target> | QueryOrderMap<Target>[]

Set default ordering.

optionalorphanRemoval

orphanRemoval?: boolean

Remove the entity when it gets disconnected from the relationship (see Cascading).

optionalinheritedpersist

persist?: boolean

Set false to define Property.

optionalinheritedprecision

precision?: number

Set precision of database column to represent the number of significant digits. (SQL only)

optionalinheritedprimary

primary?: boolean

Set true to define entity's unique primary key identifier. Alias for @PrimaryKey() decorator

@see

optionalinheritedref

ref?: boolean

Enable ScalarReference wrapper for lazy values. Use this in combination with lazy: true to have a type-safe accessor object in place of the value.

optionalreferenceColumnName

referenceColumnName?: string

Override the default database column name on the target entity (see Naming Strategy). This option is only for simple properties represented by a single column.

optionalreferencedColumnNames

referencedColumnNames?: string[]

Override the default database column name on the target entity (see Naming Strategy). This option is suitable for composite keys, where one property is represented by multiple columns.

optionalinheritedreturning

returning?: boolean

Add the property to the returning statement.

optionalinheritedruntimeType

runtimeType?: string

Runtime type of the property. This is the JS type that your property is mapped to, e.g. string or number, and is normally inferred automatically via reflect-metadata. In some cases, the inference won't work, and you might need to specify the runtimeType explicitly - the most common one is when you use a union type with null like foo: number | null.

optionalinheritedscale

scale?: number

Set scale of database column to represents the number of digits after the decimal point. (SQL only)

optionalinheritedserializedName

serializedName?: string

Specify name of key for the serialized value.

optionalinheritedserializedPrimaryKey

serializedPrimaryKey?: boolean

Set to define serialized primary key for MongoDB. (virtual) Alias for @SerializedPrimaryKey() decorator.

@see

optionalinheritedserializer

serializer?: (value: any, options?: SerializeOptions<any, never, never>) => any

Set to use serialize property. Allow to specify a callback that will be used when serializing a property.

@see

Type declaration

optionalinheritedsetter

setter?: boolean

Set true to define the properties as setter. (virtual)

@example
@Property({ setter: true })
set address(value: string) {
this._address = value.toLocaleLowerCase();
}

optionalinheritedstrategy

strategy?: LoadStrategy | select-in | joined

Override the default loading strategy for this property. This option has precedence over the global loadStrategy, but can be overridden by FindOptions.strategy.

optionalinheritedtrackChanges

trackChanges?: boolean

Set false to disable change tracking on a property level.

@see

optionalinheritedtype

type?: string | Date | uint8array | array | enumArray | unknown | AnyString | Type<any, any> | Constructor<Partial<any>> | ObjectId | Constructor<Type<any, any>> | () => unknown | ColumnType

optionalinheritedunique

unique?: string | boolean

Set column as unique for Generator. (SQL only)

optionalinheritedunsigned

unsigned?: boolean

Set column as unsigned for Generator. (SQL only)

optionalinheritedversion

version?: boolean

Set to true to enable Locking via version field. (SQL only)

optionalwhere

where?: FilterQuery<Target>