Skip to main content
Version: Next

AssignOptions <Convert>

Index

Properties

optionalconvertCustomTypes

convertCustomTypes?: Convert

assign excepts runtime values for properties using custom types. To be able to assign raw database values, you can enable the convertCustomTypes option. Defaults to false.

optionalem

When using the static assign() helper, you can pass the EntityManager instance explicitly via the em option. This is only needed when you try to assign a relation property. The value is automatically inferred from the target entity when it is managed, or when you use em.assign() instead.

optionalmerge

merge?: boolean

When assigning to a relation property, if the value is a POJO and updateByPrimaryKey is enabled, we check if the target exists in the identity map based on its primary key and call assign on it recursively. If there is no primary key provided, or the entity is not present in the context, such an entity is considered as new (resulting in INSERT query), created via em.create(). You can use merge: true to use em.merge() instead, which means there won't be any query used for persisting the relation. Defaults to false.

optionalmergeEmbeddedProperties

mergeEmbeddedProperties?: boolean

When assigning to an embedded property, the values are deeply merged with the existing data. Use mergeEmbeddedProperties: false to replace them instead. Defaults to true.

optionalmergeObjectProperties

mergeObjectProperties?: boolean

When assigning to a JSON property, the value is replaced. Use mergeObjectProperties: true to enable deep merging of the payload with the existing value. Defaults to false.

optionalonlyOwnProperties

onlyOwnProperties?: boolean

With onlyOwnProperties enabled, to-many relations are skipped, and payloads of to-one relations are converted to foreign keys. Defaults to false.

optionalonlyProperties

onlyProperties?: boolean

When you have some properties in the payload that are not represented by an entity property mapping, you can skip such unknown properties via onlyProperties: true. Defaults to false.

optionalschema

schema?: string

When assigning to a to-many relation properties (Collection) with updateNestedEntities and updateByPrimaryKey enabled (default), you can use this option to override the relation schema. This is used only when trying to find the entity reference in the current context. If it is not found, we create the relation entity using the target entity schema. The value is automatically inferred from the target entity.

optionalupdateByPrimaryKey

updateByPrimaryKey?: boolean

When assigning to a relation property with object payload and updateNestedEntities enabled (default), you can control how a payload without a primary key is handled. By default, it is considered as a new object, resulting in an INSERT query. Use updateByPrimaryKey: false to allow assigning the data on an existing relation instead. Defaults to true.

optionalupdateNestedEntities

updateNestedEntities?: boolean

Allows disabling processing of nested relations. When disabled, an object payload in place of a relation always results in an INSERT query. To assign a value of the relation, use the foreign key instead of an object. Defaults to true.