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EAAE,CAAC,CAAA;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAEhB,OAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAElB,KAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAER,KAAa,EACb,UAAkB;QAElB,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QAGR,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;CACJ;AA9kBD,gCA8kBC","file":"BaseEntity.js","sourcesContent":["import { Repository } from \"./Repository\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { DataSource } from \"../data-source\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { ObjectId } from \"../driver/mongodb/typings\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\nimport { PickKeysByType } from \"../common/PickKeysByType\"\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource used in all static methods of the BaseEntity.\n */\n private static dataSource: DataSource | null\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().hasId(this)\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().save(this, options)\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().remove(this, options) as Promise\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().softRemove(this, options)\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().recover(this, options)\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise {\n const baseEntity = this.constructor as typeof BaseEntity\n const id = baseEntity.getRepository().metadata.getEntityIdMap(this)\n if (!id) {\n throw new Error(\n `Entity doesn't have id-s set, cannot reload entity`,\n )\n }\n const reloadedEntity: BaseEntity = await baseEntity\n .getRepository()\n .findOneByOrFail(id)\n\n ObjectUtils.assign(this, reloadedEntity)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets DataSource to be used by entity.\n */\n static useDataSource(dataSource: DataSource | null) {\n this.dataSource = dataSource\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository(\n this: { new (): T } & typeof BaseEntity,\n ): Repository {\n const dataSource = (this as typeof BaseEntity).dataSource\n if (!dataSource)\n throw new Error(`DataSource is not set for this entity.`)\n return dataSource.getRepository(this)\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): EntityTarget {\n return this.getRepository().target\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n ): any {\n return this.getRepository().getId(entity)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n static createQueryBuilder(\n this: { new (): T } & typeof BaseEntity,\n alias?: string,\n ): SelectQueryBuilder {\n return this.getRepository().createQueryBuilder(alias)\n }\n\n /**\n * Creates a new entity instance.\n */\n static create(\n this: { new (): T } & typeof BaseEntity,\n ): T\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n static create(\n this: { new (): T } & typeof BaseEntity,\n entityLikeArray: DeepPartial[],\n ): T[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial,\n ): T\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities?: any,\n ) {\n return this.getRepository().create(entityOrEntities)\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge(\n this: { new (): T } & typeof BaseEntity,\n mergeIntoEntity: T,\n ...entityLikes: DeepPartial[]\n ): T {\n return this.getRepository().merge(\n mergeIntoEntity,\n ...entityLikes,\n ) as T\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial,\n ): Promise {\n const thisRepository = this.getRepository()\n return thisRepository.preload(entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n static save(\n this: { new (): T } & typeof BaseEntity,\n entities: DeepPartial[],\n options?: SaveOptions,\n ): Promise\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n static save(\n this: { new (): T } & typeof BaseEntity,\n entity: DeepPartial,\n options?: SaveOptions,\n ): Promise\n\n /**\n * Saves one or many given entities.\n */\n static save(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: DeepPartial | DeepPartial[],\n options?: SaveOptions,\n ) {\n return this.getRepository().save(entityOrEntities as any, options)\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: RemoveOptions,\n ): Promise\n\n /**\n * Removes a given entity from the database.\n */\n static remove(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: RemoveOptions,\n ): Promise\n\n /**\n * Removes one or many given entities.\n */\n static remove(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: RemoveOptions,\n ) {\n return this.getRepository().remove(entityOrEntities as any, options)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: SaveOptions,\n ): Promise\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: SaveOptions,\n ): Promise\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ) {\n return this.getRepository().softRemove(\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n static insert(\n this: { new (): T } & typeof BaseEntity,\n entity: QueryDeepPartialEntity | QueryDeepPartialEntity[],\n ): Promise {\n return this.getRepository().insert(entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n static update(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere,\n partialEntity: QueryDeepPartialEntity,\n ): Promise {\n return this.getRepository().update(criteria, partialEntity)\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities:\n | QueryDeepPartialEntity\n | QueryDeepPartialEntity[],\n conflictPathsOrOptions: string[] | UpsertOptions,\n ): Promise {\n return this.getRepository().upsert(\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n static delete(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectId\n | ObjectId[]\n | FindOptionsWhere,\n ): Promise {\n return this.getRepository().delete(criteria)\n }\n\n /**\n * Checks whether any entity exists that matches the given options.\n */\n static exists(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions,\n ): Promise {\n return this.getRepository().exists(options)\n }\n\n /**\n * Checks whether any entity exists that matches the given conditions.\n */\n static existsBy(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().existsBy(where)\n }\n\n /**\n * Counts entities that match given options.\n */\n static count(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions,\n ): Promise {\n return this.getRepository().count(options)\n }\n\n /**\n * Counts entities that match given WHERE conditions.\n */\n static countBy(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().countBy(where)\n }\n\n /**\n * Return the SUM of a column\n */\n static sum(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().sum(columnName, where)\n }\n\n /**\n * Return the AVG of a column\n */\n static average(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().average(columnName, where)\n }\n\n /**\n * Return the MIN of a column\n */\n static minimum(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().minimum(columnName, where)\n }\n\n /**\n * Return the MAX of a column\n */\n static maximum(\n this: { new (): T } & typeof BaseEntity,\n columnName: PickKeysByType,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().maximum(columnName, where)\n }\n\n /**\n * Finds entities that match given options.\n */\n static find(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions,\n ): Promise {\n return this.getRepository().find(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n */\n static findBy(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().findBy(where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions,\n ): Promise<[T[], number]> {\n return this.getRepository().findAndCount(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCountBy(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise<[T[], number]> {\n return this.getRepository().findAndCountBy(where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n static findByIds(\n this: { new (): T } & typeof BaseEntity,\n ids: any[],\n ): Promise {\n return this.getRepository().findByIds(ids)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions,\n ): Promise {\n return this.getRepository().findOne(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneBy(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().findOneBy(where)\n }\n\n /**\n * Finds first entity that matches given options.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n static findOneById(\n this: { new (): T } & typeof BaseEntity,\n id: string | number | Date | ObjectId,\n ): Promise {\n return this.getRepository().findOneById(id)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions,\n ): Promise {\n return this.getRepository().findOneOrFail(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneByOrFail(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere,\n ): Promise {\n return this.getRepository().findOneByOrFail(where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query(\n this: { new (): T } & typeof BaseEntity,\n query: string,\n parameters?: any[],\n ): Promise {\n return this.getRepository().query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear(\n this: { new (): T } & typeof BaseEntity,\n ): Promise {\n return this.getRepository().clear()\n }\n}\n"],"sourceRoot":".."}