Skip to main content

Class: abstract EntityHelper

typeorm/src.EntityHelper

Extends

  • BaseEntity

Implements

Constructors

new EntityHelper()

new EntityHelper(): EntityHelper

Returns

EntityHelper

Inherited from

BaseEntity.constructor

Accessors

target

get static target(): EntityTarget<any>

Returns object that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema instead.

Returns

EntityTarget<any>

Source

node_modules/typeorm/repository/BaseEntity.d.ts:67

Methods

hasId

hasId(): boolean

Checks if entity has an id. If entity composite compose ids, it will check them all.

Returns

boolean

Inherited from

BaseEntity.hasId

Source

node_modules/typeorm/repository/BaseEntity.d.ts:30


recover

recover(options?): Promise<EntityHelper>

Recovers a given entity in the database.

Parameters

options?: SaveOptions

Returns

Promise<EntityHelper>

Inherited from

BaseEntity.recover

Source

node_modules/typeorm/repository/BaseEntity.d.ts:47


reload

reload(): Promise<void>

Reloads entity data from the database.

Returns

Promise<void>

Inherited from

BaseEntity.reload

Source

node_modules/typeorm/repository/BaseEntity.d.ts:51


remove

remove(options?): Promise<EntityHelper>

Removes current entity from the database.

Parameters

options?: RemoveOptions

Returns

Promise<EntityHelper>

Inherited from

BaseEntity.remove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:39


save

save(options?): Promise<EntityHelper>

Saves current entity in the database. If entity does not exist in the database then inserts, otherwise updates.

Parameters

options?: SaveOptions

Returns

Promise<EntityHelper>

Inherited from

BaseEntity.save

Source

node_modules/typeorm/repository/BaseEntity.d.ts:35


softRemove

softRemove(options?): Promise<EntityHelper>

Records the delete date of current entity.

Parameters

options?: SaveOptions

Returns

Promise<EntityHelper>

Inherited from

BaseEntity.softRemove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:43


average

static average<T>(this, columnName, where): Promise<number>

Return the AVG of a column

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

columnName: PickKeysByType<T, number>

where: FindOptionsWhere<T>

Returns

Promise<number>

Inherited from

BaseEntity.average

Source

node_modules/typeorm/repository/BaseEntity.d.ts:217


clear

static clear<T>(this): Promise<void>

Clears all the data from the given table/collection (truncates/drops it).

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

Returns

Promise<void>

Inherited from

BaseEntity.clear

Source

node_modules/typeorm/repository/BaseEntity.d.ts:319


count

static count<T>(this, options?): Promise<number>

Counts entities that match given options.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

options?: FindManyOptions<T>

Returns

Promise<number>

Inherited from

BaseEntity.count

Source

node_modules/typeorm/repository/BaseEntity.d.ts:199


countBy

static countBy<T>(this, where): Promise<number>

Counts entities that match given WHERE conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

where: FindOptionsWhere<T>

Returns

Promise<number>

Inherited from

BaseEntity.countBy

Source

node_modules/typeorm/repository/BaseEntity.d.ts:205


create

create(this)

static create<T>(this): T

Creates a new entity instance.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

Returns

T

Inherited from

BaseEntity.create

Source

node_modules/typeorm/repository/BaseEntity.d.ts:88

create(this, entityLikeArray)

static create<T>(this, entityLikeArray): T[]

Creates a new entities and copies all entity properties from given objects into their new entities. Note that it copies only properties that present in entity schema.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entityLikeArray: DeepPartial<T>[]

Returns

T[]

Inherited from

BaseEntity.create

Source

node_modules/typeorm/repository/BaseEntity.d.ts:95

create(this, entityLike)

static create<T>(this, entityLike): T

Creates a new entity instance and copies all entity properties from this object into a new entity. Note that it copies only properties that present in entity schema.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entityLike: DeepPartial<T>

Returns

T

Inherited from

BaseEntity.create

Source

node_modules/typeorm/repository/BaseEntity.d.ts:102


createQueryBuilder

static createQueryBuilder<T>(this, alias?): SelectQueryBuilder<T>

Creates a new query builder that can be used to build a SQL query.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

alias?: string

Returns

SelectQueryBuilder<T>

Inherited from

BaseEntity.createQueryBuilder

Source

node_modules/typeorm/repository/BaseEntity.d.ts:82


delete

static delete<T>(this, criteria): Promise<DeleteResult>

Deletes entities by a given criteria. Unlike remove method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient DELETE query. Does not check if entity exist in the database.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

criteria: string | number | string[] | number[] | Date | ObjectId | Date[] | ObjectId[] | FindOptionsWhere<T>

Returns

Promise<DeleteResult>

Inherited from

BaseEntity.delete

Source

node_modules/typeorm/repository/BaseEntity.d.ts:193


find

static find<T>(this, options?): Promise<T[]>

Finds entities that match given options.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

options?: FindManyOptions<T>

Returns

Promise<T[]>

Inherited from

BaseEntity.find

Source

node_modules/typeorm/repository/BaseEntity.d.ts:235


findAndCount

static findAndCount<T>(this, options?): Promise<[T[], number]>

Finds entities that match given find options. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

options?: FindManyOptions<T>

Returns

Promise<[T[], number]>

Inherited from

BaseEntity.findAndCount

Source

node_modules/typeorm/repository/BaseEntity.d.ts:249


findAndCountBy

static findAndCountBy<T>(this, where): Promise<[T[], number]>

Finds entities that match given WHERE conditions. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

where: FindOptionsWhere<T>

Returns

Promise<[T[], number]>

Inherited from

BaseEntity.findAndCountBy

Source

node_modules/typeorm/repository/BaseEntity.d.ts:257


findBy

static findBy<T>(this, where): Promise<T[]>

Finds entities that match given WHERE conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

where: FindOptionsWhere<T>

Returns

Promise<T[]>

Inherited from

BaseEntity.findBy

Source

node_modules/typeorm/repository/BaseEntity.d.ts:241


findByIds

static findByIds<T>(this, ids): Promise<T[]>

Finds entities by ids. Optionally find options can be applied.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

ids: any[]

Returns

Promise<T[]>

Inherited from

BaseEntity.findByIds

Deprecated

use findBy method instead in conjunction with In operator, for example:

.findBy({ id: In([1, 2, 3]) })

Source

node_modules/typeorm/repository/BaseEntity.d.ts:270


findOne

static findOne<T>(this, options): Promise<T>

Finds first entity that matches given conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

options: FindOneOptions<T>

Returns

Promise<T>

Inherited from

BaseEntity.findOne

Source

node_modules/typeorm/repository/BaseEntity.d.ts:276


findOneBy

static findOneBy<T>(this, where): Promise<T>

Finds first entity that matches given conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

where: FindOptionsWhere<T>

Returns

Promise<T>

Inherited from

BaseEntity.findOneBy

Source

node_modules/typeorm/repository/BaseEntity.d.ts:282


findOneById

static findOneById<T>(this, id): Promise<T>

Finds first entity that matches given options.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

id: string | number | Date | ObjectId

Returns

Promise<T>

Inherited from

BaseEntity.findOneById

Deprecated

use findOneBy method instead in conjunction with In operator, for example:

.findOneBy({ id: 1 // where "id" is your primary column name })

Source

node_modules/typeorm/repository/BaseEntity.d.ts:294


findOneByOrFail

static findOneByOrFail<T>(this, where): Promise<T>

Finds first entity that matches given conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

where: FindOptionsWhere<T>

Returns

Promise<T>

Inherited from

BaseEntity.findOneByOrFail

Source

node_modules/typeorm/repository/BaseEntity.d.ts:306


findOneOrFail

static findOneOrFail<T>(this, options): Promise<T>

Finds first entity that matches given conditions.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

options: FindOneOptions<T>

Returns

Promise<T>

Inherited from

BaseEntity.findOneOrFail

Source

node_modules/typeorm/repository/BaseEntity.d.ts:300


getId

static getId<T>(this, entity): any

Gets entity mixed id.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entity: T

Returns

any

Inherited from

BaseEntity.getId

Source

node_modules/typeorm/repository/BaseEntity.d.ts:76


getRepository

static getRepository<T>(this): Repository<T>

Gets current entity's Repository.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

Returns

Repository<T>

Inherited from

BaseEntity.getRepository

Source

node_modules/typeorm/repository/BaseEntity.d.ts:59


hasId

static hasId(entity): boolean

Checks entity has an id. If entity composite compose ids, it will check them all.

Parameters

entity: BaseEntity

Returns

boolean

Inherited from

BaseEntity.hasId

Source

node_modules/typeorm/repository/BaseEntity.d.ts:72


insert

static insert<T>(this, entity): Promise<InsertResult>

Inserts a given entity into the database. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT query. Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entity: _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T> | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>[]

Returns

Promise<InsertResult>

Inherited from

BaseEntity.insert

Source

node_modules/typeorm/repository/BaseEntity.d.ts:167


maximum

static maximum<T>(this, columnName, where): Promise<number>

Return the MAX of a column

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

columnName: PickKeysByType<T, number>

where: FindOptionsWhere<T>

Returns

Promise<number>

Inherited from

BaseEntity.maximum

Source

node_modules/typeorm/repository/BaseEntity.d.ts:229


merge

static merge<T>(this, mergeIntoEntity, ...entityLikes): T

Merges multiple entities (or entity-like objects) into a given entity.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

mergeIntoEntity: T

▪ ...entityLikes: DeepPartial<T>[]

Returns

T

Inherited from

BaseEntity.merge

Source

node_modules/typeorm/repository/BaseEntity.d.ts:108


minimum

static minimum<T>(this, columnName, where): Promise<number>

Return the MIN of a column

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

columnName: PickKeysByType<T, number>

where: FindOptionsWhere<T>

Returns

Promise<number>

Inherited from

BaseEntity.minimum

Source

node_modules/typeorm/repository/BaseEntity.d.ts:223


preload

static preload<T>(this, entityLike): Promise<T>

Creates a new entity from the given plain javascript object. If entity already exist in the database, then it loads it (and everything related to it), replaces all values with the new ones from the given object and returns this new entity. This new entity is actually a loaded from the db entity with all properties replaced from the new object.

Note that given entity-like object must have an entity id / primary key to find entity by. Returns undefined if entity with given id was not found.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entityLike: DeepPartial<T>

Returns

Promise<T>

Inherited from

BaseEntity.preload

Source

node_modules/typeorm/repository/BaseEntity.d.ts:120


query

static query<T>(this, query, parameters?): Promise<any>

Executes a raw SQL query and returns a raw database results. Raw query execution is supported only by relational databases (MongoDB is not supported).

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

query: string

parameters?: any[]

Returns

Promise<any>

Inherited from

BaseEntity.query

Source

node_modules/typeorm/repository/BaseEntity.d.ts:313


remove

remove(this, entities, options)

static remove<T>(this, entities, options?): Promise<T[]>

Removes a given entities from the database.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entities: T[]

options?: RemoveOptions

Returns

Promise<T[]>

Inherited from

BaseEntity.remove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:140

remove(this, entity, options)

static remove<T>(this, entity, options?): Promise<T>

Removes a given entity from the database.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entity: T

options?: RemoveOptions

Returns

Promise<T>

Inherited from

BaseEntity.remove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:146


save

save(this, entities, options)

static save<T>(this, entities, options?): Promise<T[]>

Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entities: DeepPartial<T>[]

options?: SaveOptions

Returns

Promise<T[]>

Inherited from

BaseEntity.save

Source

node_modules/typeorm/repository/BaseEntity.d.ts:127

save(this, entity, options)

static save<T>(this, entity, options?): Promise<T>

Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entity: DeepPartial<T>

options?: SaveOptions

Returns

Promise<T>

Inherited from

BaseEntity.save

Source

node_modules/typeorm/repository/BaseEntity.d.ts:134


softRemove

softRemove(this, entities, options)

static softRemove<T>(this, entities, options?): Promise<T[]>

Records the delete date of all given entities.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entities: T[]

options?: SaveOptions

Returns

Promise<T[]>

Inherited from

BaseEntity.softRemove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:152

softRemove(this, entity, options)

static softRemove<T>(this, entity, options?): Promise<T>

Records the delete date of a given entity.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entity: T

options?: SaveOptions

Returns

Promise<T>

Inherited from

BaseEntity.softRemove

Source

node_modules/typeorm/repository/BaseEntity.d.ts:158


sum

static sum<T>(this, columnName, where): Promise<number>

Return the SUM of a column

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

columnName: PickKeysByType<T, number>

where: FindOptionsWhere<T>

Returns

Promise<number>

Inherited from

BaseEntity.sum

Source

node_modules/typeorm/repository/BaseEntity.d.ts:211


update

static update<T>(this, criteria, partialEntity): Promise<UpdateResult>

Updates entity partially. Entity can be found by a given conditions. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient UPDATE query. Does not check if entity exist in the database.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

criteria: string | number | string[] | number[] | Date | ObjectId | Date[] | ObjectId[] | FindOptionsWhere<T>

partialEntity: _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>

Returns

Promise<UpdateResult>

Inherited from

BaseEntity.update

Source

node_modules/typeorm/repository/BaseEntity.d.ts:176


upsert

static upsert<T>(this, entityOrEntities, conflictPathsOrOptions): Promise<InsertResult>

Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.

Type parameters

T extends BaseEntity

Parameters

this: () => T & typeof BaseEntity

entityOrEntities: _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T> | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>[]

conflictPathsOrOptions: string[] | UpsertOptions<T>

Returns

Promise<InsertResult>

Inherited from

BaseEntity.upsert

Source

node_modules/typeorm/repository/BaseEntity.d.ts:184


useDataSource

static useDataSource(dataSource): void

Sets DataSource to be used by entity.

Parameters

dataSource: DataSource

Returns

void

Inherited from

BaseEntity.useDataSource

Source

node_modules/typeorm/repository/BaseEntity.d.ts:55


Generated using typedoc-plugin-markdown and TypeDoc