typeorm 0.2.42-dev.0626ed1 → 0.2.42-dev.1cfd7b9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/browser/common/RelationType.d.ts +14 -0
- package/browser/common/RelationType.js +3 -0
- package/browser/common/RelationType.js.map +1 -0
- package/browser/connection/Connection.d.ts +3 -3
- package/browser/connection/Connection.js +46 -31
- package/browser/connection/Connection.js.map +1 -1
- package/browser/connection/ConnectionMetadataBuilder.d.ts +3 -3
- package/browser/connection/ConnectionMetadataBuilder.js +54 -22
- package/browser/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/browser/connection/ConnectionOptionsReader.js +33 -28
- package/browser/connection/ConnectionOptionsReader.js.map +1 -1
- package/browser/decorator/Unique.d.ts +5 -4
- package/browser/decorator/Unique.js +7 -3
- package/browser/decorator/Unique.js.map +1 -1
- package/browser/decorator/options/RelationOptions.d.ts +1 -1
- package/browser/decorator/options/RelationOptions.js.map +1 -1
- package/browser/decorator/options/UniqueOptions.d.ts +10 -0
- package/browser/decorator/options/UniqueOptions.js +3 -0
- package/browser/decorator/options/UniqueOptions.js.map +1 -0
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +11 -4
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +1 -1
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqlite/SqliteDriver.js +11 -10
- package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.d.ts +2 -2
- package/browser/entity-manager/EntityManager.js +1 -1
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.js +2 -1
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/browser/entity-schema/EntitySchemaTransformer.js +2 -1
- package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/browser/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/browser/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/browser/find-options/operator/Like.d.ts +1 -1
- package/browser/find-options/operator/Like.js +1 -1
- package/browser/find-options/operator/Like.js.map +1 -1
- package/browser/globals.js +34 -7
- package/browser/globals.js.map +1 -1
- package/browser/index.d.ts +2 -0
- package/browser/index.js +2 -0
- package/browser/index.js.map +1 -1
- package/browser/metadata/RelationMetadata.d.ts +1 -1
- package/browser/metadata/RelationMetadata.js.map +1 -1
- package/browser/metadata/UniqueMetadata.d.ts +5 -0
- package/browser/metadata/UniqueMetadata.js +1 -0
- package/browser/metadata/UniqueMetadata.js.map +1 -1
- package/browser/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/browser/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataValidator.js +1 -0
- package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +1 -1
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/browser/query-builder/DeleteQueryBuilder.d.ts +4 -2
- package/browser/query-builder/DeleteQueryBuilder.js +4 -2
- package/browser/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.d.ts +1 -1
- package/browser/query-builder/InsertQueryBuilder.js +1 -1
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/NotBrackets.d.ts +7 -0
- package/browser/query-builder/NotBrackets.js +16 -0
- package/browser/query-builder/NotBrackets.js.map +1 -0
- package/browser/query-builder/QueryBuilder.d.ts +3 -2
- package/browser/query-builder/QueryBuilder.js +2 -1
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/RelationLoader.js +11 -6
- package/browser/query-builder/RelationLoader.js.map +1 -1
- package/browser/query-builder/RelationQueryBuilder.d.ts +1 -1
- package/browser/query-builder/RelationQueryBuilder.js +1 -1
- package/browser/query-builder/RelationQueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +1 -1
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.d.ts +4 -2
- package/browser/query-builder/UpdateQueryBuilder.js +11 -6
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/query-builder/WhereExpressionBuilder.d.ts +3 -1
- package/browser/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/browser/repository/AbstractRepository.d.ts +2 -2
- package/browser/repository/AbstractRepository.js +2 -2
- package/browser/repository/AbstractRepository.js.map +1 -1
- package/browser/repository/BaseEntity.d.ts +1 -1
- package/browser/repository/BaseEntity.js +1 -1
- package/browser/repository/BaseEntity.js.map +1 -1
- package/browser/repository/Repository.d.ts +1 -1
- package/browser/repository/Repository.js +1 -1
- package/browser/repository/Repository.js.map +1 -1
- package/browser/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/browser/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/browser/schema-builder/table/TableUnique.d.ts +5 -0
- package/browser/schema-builder/table/TableUnique.js +5 -2
- package/browser/schema-builder/table/TableUnique.js.map +1 -1
- package/browser/util/DirectoryExportedClassesLoader.d.ts +1 -1
- package/browser/util/DirectoryExportedClassesLoader.js +55 -31
- package/browser/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/browser/util/ImportUtils.d.ts +1 -0
- package/browser/util/ImportUtils.js +90 -0
- package/browser/util/ImportUtils.js.map +1 -0
- package/commands/InitCommand.d.ts +9 -7
- package/commands/InitCommand.js +72 -43
- package/commands/InitCommand.js.map +1 -1
- package/commands/QueryCommand.d.ts +1 -1
- package/commands/QueryCommand.js +1 -1
- package/commands/QueryCommand.js.map +1 -1
- package/common/RelationType.d.ts +14 -0
- package/common/RelationType.js +4 -0
- package/common/RelationType.js.map +1 -0
- package/connection/Connection.d.ts +3 -3
- package/connection/Connection.js +46 -31
- package/connection/Connection.js.map +1 -1
- package/connection/ConnectionMetadataBuilder.d.ts +3 -3
- package/connection/ConnectionMetadataBuilder.js +53 -21
- package/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/connection/ConnectionOptionsReader.js +32 -27
- package/connection/ConnectionOptionsReader.js.map +1 -1
- package/decorator/Unique.d.ts +5 -4
- package/decorator/Unique.js +7 -3
- package/decorator/Unique.js.map +1 -1
- package/decorator/options/RelationOptions.d.ts +1 -1
- package/decorator/options/RelationOptions.js.map +1 -1
- package/decorator/options/UniqueOptions.d.ts +10 -0
- package/decorator/options/UniqueOptions.js +4 -0
- package/decorator/options/UniqueOptions.js.map +1 -0
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/better-sqlite3/BetterSqlite3Driver.js +7 -5
- package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +1 -1
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +1 -1
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +11 -4
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +1 -1
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqlite/SqliteDriver.js +11 -10
- package/driver/sqlite/SqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.d.ts +2 -2
- package/entity-manager/EntityManager.js +1 -1
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.js +2 -1
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaRelationOptions.d.ts +1 -1
- package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/entity-schema/EntitySchemaTransformer.js +2 -1
- package/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/entity-schema/EntitySchemaUniqueOptions.d.ts +5 -0
- package/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/find-options/operator/Like.d.ts +1 -1
- package/find-options/operator/Like.js +1 -1
- package/find-options/operator/Like.js.map +1 -1
- package/globals.js +33 -6
- package/globals.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/index.mjs +352 -0
- package/metadata/RelationMetadata.d.ts +1 -1
- package/metadata/RelationMetadata.js.map +1 -1
- package/metadata/UniqueMetadata.d.ts +5 -0
- package/metadata/UniqueMetadata.js +1 -0
- package/metadata/UniqueMetadata.js.map +1 -1
- package/metadata-args/UniqueMetadataArgs.d.ts +5 -0
- package/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/metadata-builder/EntityMetadataValidator.js +1 -0
- package/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/migration/MigrationExecutor.js +1 -1
- package/migration/MigrationExecutor.js.map +1 -1
- package/package.json +1 -1
- package/persistence/subject-builder/OneToManySubjectBuilder.js +3 -0
- package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/query-builder/DeleteQueryBuilder.d.ts +4 -2
- package/query-builder/DeleteQueryBuilder.js +4 -2
- package/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/query-builder/InsertQueryBuilder.d.ts +1 -1
- package/query-builder/InsertQueryBuilder.js +1 -1
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/NotBrackets.d.ts +7 -0
- package/query-builder/NotBrackets.js +19 -0
- package/query-builder/NotBrackets.js.map +1 -0
- package/query-builder/QueryBuilder.d.ts +3 -2
- package/query-builder/QueryBuilder.js +2 -1
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/RelationLoader.js +11 -6
- package/query-builder/RelationLoader.js.map +1 -1
- package/query-builder/RelationQueryBuilder.d.ts +1 -1
- package/query-builder/RelationQueryBuilder.js +1 -1
- package/query-builder/RelationQueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/query-builder/SelectQueryBuilder.js +1 -1
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-builder/SoftDeleteQueryBuilder.d.ts +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.d.ts +4 -2
- package/query-builder/UpdateQueryBuilder.js +11 -6
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/query-builder/WhereExpressionBuilder.d.ts +3 -1
- package/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/repository/AbstractRepository.d.ts +2 -2
- package/repository/AbstractRepository.js +2 -2
- package/repository/AbstractRepository.js.map +1 -1
- package/repository/BaseEntity.d.ts +1 -1
- package/repository/BaseEntity.js +1 -1
- package/repository/BaseEntity.js.map +1 -1
- package/repository/Repository.d.ts +1 -1
- package/repository/Repository.js +1 -1
- package/repository/Repository.js.map +1 -1
- package/schema-builder/options/TableUniqueOptions.d.ts +5 -0
- package/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/schema-builder/table/TableUnique.d.ts +5 -0
- package/schema-builder/table/TableUnique.js +5 -2
- package/schema-builder/table/TableUnique.js.map +1 -1
- package/util/DirectoryExportedClassesLoader.d.ts +1 -1
- package/util/DirectoryExportedClassesLoader.js +54 -31
- package/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/util/ImportUtils.d.ts +1 -0
- package/util/ImportUtils.js +94 -0
- package/util/ImportUtils.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAczC,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAIhD;;GAEG;AACH;IAAA;IAmYA,CAAC;IAvXG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,0BAAK,GAAL;QACI,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,yBAAI,GAAJ,UAAK,OAAqB;QACtB,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;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BAA0D;QAC9H,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,mBAA0B,CAAC,CAAC;IACpF,CAAC;IAiBD;;OAEG;IACI,kBAAO,GAAd,UAA0D,mBAAqF,EAAE,YAAgC;QAC7K,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;IAiBD;;OAEG;IACI,wBAAa,GAApB,UAAgE,mBAAqF,EAAE,YAAgC;QACnL,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,mBAA0B,EAAE,YAAY,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACI,gBAAK,GAAZ,UAAwD,KAAa,EAAE,UAAkB;QACrF,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACI,gBAAK,GAAZ;QACI,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEL,iBAAC;AAAD,CAnYA,AAmYC,IAAA","file":"BaseEntity.js","sourcesContent":["import {Repository} from \"./Repository\";\nimport {getConnection} from \"../globals\";\nimport {FindConditions} from \"../find-options/FindConditions\";\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 {Connection} from \"../connection/Connection\";\nimport {ObjectType} from \"../common/ObjectType\";\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\";\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used in all static methods of the BaseEntity.\n */\n // @ts-ignore: Unused variable which is actually used\n private static usedConnection?: Connection;\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 return (this.constructor as any).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<this> {\n return (this.constructor as any).getRepository().save(this, options);\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n return (this.constructor as any).getRepository().remove(this, options);\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().softRemove(this, options);\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().recover(this, options);\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const base: any = this.constructor;\n const newestEntity: BaseEntity = await base.getRepository().findOneOrFail(base.getId(this));\n\n ObjectUtils.assign(this, newestEntity);\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets connection to be used by entity.\n */\n static useConnection(connection: Connection) {\n this.usedConnection = connection;\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(this: ObjectType<T>): Repository<T> {\n const connection: Connection = (this as any).usedConnection || getConnection();\n return connection.getRepository<T>(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(): Function|string {\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<T extends BaseEntity>(this: ObjectType<T>, entity: T): any {\n return (this as any).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<T extends BaseEntity>(this: ObjectType<T>, alias?: string): SelectQueryBuilder<T> {\n return (this as any).getRepository().createQueryBuilder(alias);\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(this: ObjectType<T>): 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<T extends BaseEntity>(this: ObjectType<T>, entityLikeArray: DeepPartial<T>[]): 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<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): T;\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<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities?: any): T {\n return (this as any).getRepository().create(entityOrEntities);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(this: ObjectType<T>, mergeIntoEntity: T, ...entityLikes: DeepPartial<T>[]): T {\n return (this as any).getRepository().merge(mergeIntoEntity, ...entityLikes);\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<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): Promise<T|undefined> {\n return (this as any).getRepository().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<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\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<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().save(entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: RemoveOptions): Promise<T[]>;\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: RemoveOptions): Promise<T>;\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: RemoveOptions): Promise<T|T[]> {\n return (this as any).getRepository().remove(entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().softRemove(entityOrEntities as any, options);\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<T extends BaseEntity>(this: ObjectType<T>, entity: QueryDeepPartialEntity<T>|QueryDeepPartialEntity<T>[], options?: SaveOptions): Promise<InsertResult> {\n return (this as any).getRepository().insert(entity, options);\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<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, partialEntity: QueryDeepPartialEntity<T>, options?: SaveOptions): Promise<UpdateResult> {\n return (this as any).getRepository().update(criteria, partialEntity, options);\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<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity, \n entityOrEntities: QueryDeepPartialEntity<T> | (QueryDeepPartialEntity<T>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<T>): Promise<InsertResult> {\n return this.getRepository<T>().upsert(entityOrEntities, conflictPathsOrOptions);\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<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, options?: RemoveOptions): Promise<DeleteResult> {\n return (this as any).getRepository().delete(criteria, options);\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<number> {\n return (this as any).getRepository().count(optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().find(optionsOrConditions as any);\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<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<[ T[], number ]> {\n return (this as any).getRepository().findAndCount(optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().findByIds(ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T|undefined> {\n return (this as any).getRepository().findOne(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T> {\n return (this as any).getRepository().findOneOrFail(optionsOrConditions as any, maybeOptions);\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<T extends BaseEntity>(this: ObjectType<T>, query: string, parameters?: any[]): Promise<any> {\n return (this as any).getRepository().query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(this: ObjectType<T>, ): Promise<void> {\n return (this as any).getRepository().clear();\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":";AACA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAczC,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAIhD;;GAEG;AACH;IAAA;IAmYA,CAAC;IAvXG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,0BAAK,GAAL;QACI,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,yBAAI,GAAJ,UAAK,OAAqB;QACtB,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,2BAAM,GAAN,UAAO,OAAuB;QAC1B,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED;;OAEG;IACH,+BAAU,GAAV,UAAW,OAAqB;QAC5B,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,4BAAO,GAAP,UAAQ,OAAqB;QACzB,OAAQ,IAAI,CAAC,WAAmB,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACG,2BAAM,GA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;QACrF,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACI,gBAAK,GAAZ;QACI,OAAQ,IAAY,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC;IACjD,CAAC;IAEL,iBAAC;AAAD,CAnYA,AAmYC,IAAA","file":"BaseEntity.js","sourcesContent":["import {Repository} from \"./Repository\";\nimport {getConnection} from \"../globals\";\nimport {FindConditions} from \"../find-options/FindConditions\";\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 {Connection} from \"../connection/Connection\";\nimport {ObjectType} from \"../common/ObjectType\";\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\";\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used in all static methods of the BaseEntity.\n */\n // @ts-ignore: Unused variable which is actually used\n private static usedConnection?: Connection;\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 return (this.constructor as any).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<this> {\n return (this.constructor as any).getRepository().save(this, options);\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n return (this.constructor as any).getRepository().remove(this, options);\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().softRemove(this, options);\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n return (this.constructor as any).getRepository().recover(this, options);\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const base: any = this.constructor;\n const newestEntity: BaseEntity = await base.getRepository().findOneOrFail(base.getId(this));\n\n ObjectUtils.assign(this, newestEntity);\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets connection to be used by entity.\n */\n static useConnection(connection: Connection) {\n this.usedConnection = connection;\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(this: ObjectType<T>): Repository<T> {\n const connection: Connection = (this as any).usedConnection || getConnection();\n return connection.getRepository<T>(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(): Function|string {\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<T extends BaseEntity>(this: ObjectType<T>, entity: T): any {\n return (this as any).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<T extends BaseEntity>(this: ObjectType<T>, alias?: string): SelectQueryBuilder<T> {\n return (this as any).getRepository().createQueryBuilder(alias);\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(this: ObjectType<T>): 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<T extends BaseEntity>(this: ObjectType<T>, entityLikeArray: DeepPartial<T>[]): 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<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): T;\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<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities?: any): T {\n return (this as any).getRepository().create(entityOrEntities);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(this: ObjectType<T>, mergeIntoEntity: T, ...entityLikes: DeepPartial<T>[]): T {\n return (this as any).getRepository().merge(mergeIntoEntity, ...entityLikes);\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<T extends BaseEntity>(this: ObjectType<T>, entityLike: DeepPartial<T>): Promise<T|undefined> {\n return (this as any).getRepository().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<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\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<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().save(entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: RemoveOptions): Promise<T[]>;\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: RemoveOptions): Promise<T>;\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: RemoveOptions): Promise<T|T[]> {\n return (this as any).getRepository().remove(entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entities: T[], options?: SaveOptions): Promise<T[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entity: T, options?: SaveOptions): Promise<T>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(this: ObjectType<T>, entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return (this as any).getRepository().softRemove(entityOrEntities as any, options);\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<T extends BaseEntity>(this: ObjectType<T>, entity: QueryDeepPartialEntity<T>|QueryDeepPartialEntity<T>[], options?: SaveOptions): Promise<InsertResult> {\n return (this as any).getRepository().insert(entity, options);\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<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, partialEntity: QueryDeepPartialEntity<T>, options?: SaveOptions): Promise<UpdateResult> {\n return (this as any).getRepository().update(criteria, partialEntity, options);\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<T extends BaseEntity>(this: ObjectType<T> & typeof BaseEntity,\n entityOrEntities: QueryDeepPartialEntity<T> | (QueryDeepPartialEntity<T>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<T>): Promise<InsertResult> {\n return this.getRepository<T>().upsert(entityOrEntities, conflictPathsOrOptions);\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<T extends BaseEntity>(this: ObjectType<T>, criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<T>, options?: RemoveOptions): Promise<DeleteResult> {\n return (this as any).getRepository().delete(criteria, options);\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n static count<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<number> {\n return (this as any).getRepository().count(optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n static find<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().find(optionsOrConditions as any);\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<T extends BaseEntity>(this: ObjectType<T>, options?: FindManyOptions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>): Promise<[ T[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<[ T[], number ]> {\n return (this as any).getRepository().findAndCount(optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], options?: FindManyOptions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], conditions?: FindConditions<T>): Promise<T[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n static findByIds<T extends BaseEntity>(this: ObjectType<T>, ids: any[], optionsOrConditions?: FindManyOptions<T>|FindConditions<T>): Promise<T[]> {\n return (this as any).getRepository().findByIds(ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T|undefined> {\n return (this as any).getRepository().findOne(optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, id?: string|number|Date|ObjectID, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given options.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, conditions?: FindConditions<T>, options?: FindOneOptions<T>): Promise<T>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(this: ObjectType<T>, optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<T>|FindConditions<T>, maybeOptions?: FindOneOptions<T>): Promise<T> {\n return (this as any).getRepository().findOneOrFail(optionsOrConditions as any, maybeOptions);\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<T extends BaseEntity>(this: ObjectType<T>, query: string, parameters?: any[]): Promise<any> {\n return (this as any).getRepository().query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(this: ObjectType<T>, ): Promise<void> {\n return (this as any).getRepository().clear();\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -32,7 +32,7 @@ export declare class Repository<Entity extends ObjectLiteral> {
|
|
|
32
32
|
*/
|
|
33
33
|
readonly queryRunner?: QueryRunner;
|
|
34
34
|
/**
|
|
35
|
-
* Creates a new query builder that can be used to build a
|
|
35
|
+
* Creates a new query builder that can be used to build a SQL query.
|
|
36
36
|
*/
|
|
37
37
|
createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity>;
|
|
38
38
|
/**
|
|
@@ -9,7 +9,7 @@ var Repository = /** @class */ (function () {
|
|
|
9
9
|
// Public Methods
|
|
10
10
|
// -------------------------------------------------------------------------
|
|
11
11
|
/**
|
|
12
|
-
* Creates a new query builder that can be used to build a
|
|
12
|
+
* Creates a new query builder that can be used to build a SQL query.
|
|
13
13
|
*/
|
|
14
14
|
Repository.prototype.createQueryBuilder = function (alias, queryRunner) {
|
|
15
15
|
return this.manager.createQueryBuilder(this.metadata.target, alias || this.metadata.targetName, queryRunner || this.queryRunner);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/repository/Repository.ts"],"names":[],"mappings":";AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,uCAAkB,GAAlB,UAAmB,KAAc,EAAE,WAAyB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAS,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACpJ,CAAC;IAOD,sBAAI,8BAAM;QALV;;;;WAIG;aACH;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;;;OAAA;IAED;;;OAGG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,I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ED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAjaA,AAiaC,IAAA","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a sql query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\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 get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\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 are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity;\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\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 preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, 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 save<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\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 save<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\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 save<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\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 save<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\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 insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, 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 update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, 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 upsert(\n entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult> {\n return this.manager.upsert(this.metadata.target as any, entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save 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 delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\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 findAndCount(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\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 query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/repository/Repository.ts"],"names":[],"mappings":";AAkBA;;GAEG;AACH;IAAA;IAiaA,CAAC;IA5YG,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,uCAAkB,GAAlB,UAAmB,KAAc,EAAE,WAAyB;QACxD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAS,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACpJ,CAAC;IAOD,sBAAI,8BAAM;QALV;;;;WAIG;aACH;YACI,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;;;OAAA;IAED;;;OAGG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,0BAAK,GAAL,UAAM,MAAc;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IAmBD;;;OAGG;IACH,2BAAM,GAAN,UAAO,iCAA6E;QAChF,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAM,IAAI,CAAC,QAAQ,CAAC,MAAa,EAAE,iCAAwC,CAAC,CAAC;IAC3G,CAAC;IAED;;OAEG;IACH,0BAAK,GAA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,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAED;;OAEG;IACH,8BAAS,GAAT,UAAU,UAAkC,EAAE,YAAoB,EAAE,KAAsB;QACtF,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IACzF,CAAC;IAEL,iBAAC;AAAD,CAjaA,AAiaC,IAAA","file":"Repository.js","sourcesContent":["import {EntityMetadata} from \"../metadata/EntityMetadata\";\nimport {FindManyOptions} from \"../find-options/FindManyOptions\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {FindOneOptions} from \"../find-options/FindOneOptions\";\nimport {DeepPartial} from \"../common/DeepPartial\";\nimport {SaveOptions} from \"./SaveOptions\";\nimport {RemoveOptions} from \"./RemoveOptions\";\nimport {EntityManager} from \"../entity-manager/EntityManager\";\nimport {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {SelectQueryBuilder} from \"../query-builder/SelectQueryBuilder\";\nimport {DeleteResult} from \"../query-builder/result/DeleteResult\";\nimport {UpdateResult} from \"../query-builder/result/UpdateResult\";\nimport {InsertResult} from \"../query-builder/result/InsertResult\";\nimport {QueryDeepPartialEntity} from \"../query-builder/QueryPartialEntity\";\nimport {ObjectID} from \"../driver/mongodb/typings\";\nimport {FindConditions} from \"../find-options/FindConditions\";\nimport {UpsertOptions} from \"./UpsertOptions\";\n\n/**\n * Repository is supposed to work with your entity objects. Find entities, insert, update, delete, etc.\n */\nexport class Repository<Entity extends ObjectLiteral> {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Entity Manager used by this repository.\n */\n readonly manager: EntityManager;\n\n /**\n * Entity metadata of the entity current repository manages.\n */\n readonly metadata: EntityMetadata;\n\n /**\n * Query runner provider used for this repository.\n */\n readonly queryRunner?: QueryRunner;\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n createQueryBuilder(alias?: string, queryRunner?: QueryRunner): SelectQueryBuilder<Entity> {\n return this.manager.createQueryBuilder<Entity>(this.metadata.target as any, alias || this.metadata.targetName, queryRunner || this.queryRunner);\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 get target(): Function|string {\n return this.metadata.target;\n }\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(entity: Entity): boolean {\n return this.manager.hasId(this.metadata.target, entity);\n }\n\n /**\n * Gets entity mixed id.\n */\n getId(entity: Entity): any {\n return this.manager.getId(this.metadata.target, entity);\n }\n\n /**\n * Creates a new entity instance.\n */\n create(): Entity;\n\n /**\n * Creates new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that are present in entity schema.\n */\n create(entityLikeArray: DeepPartial<Entity>[]): Entity[];\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 are present in entity schema.\n */\n create(entityLike: DeepPartial<Entity>): Entity;\n\n /**\n * Creates a new entity instance or instances.\n * Can copy properties from the given object into new entities.\n */\n create(plainEntityLikeOrPlainEntityLikes?: DeepPartial<Entity>|DeepPartial<Entity>[]): Entity|Entity[] {\n return this.manager.create<any>(this.metadata.target as any, plainEntityLikeOrPlainEntityLikes as any);\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n merge(mergeIntoEntity: Entity, ...entityLikes: DeepPartial<Entity>[]): Entity {\n return this.manager.merge(this.metadata.target as any, mergeIntoEntity, ...entityLikes);\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 preload(entityLike: DeepPartial<Entity>): Promise<Entity|undefined> {\n return this.manager.preload(this.metadata.target as any, 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 save<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\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 save<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\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 save<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\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 save<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Saves one or many given entities.\n */\n save<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.save<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Removes a given entities from the database.\n */\n remove(entities: Entity[], options?: RemoveOptions): Promise<Entity[]>;\n\n /**\n * Removes a given entity from the database.\n */\n remove(entity: Entity, options?: RemoveOptions): Promise<Entity>;\n\n /**\n * Removes one or many given entities.\n */\n remove(entityOrEntities: Entity|Entity[], options?: RemoveOptions): Promise<Entity|Entity[]> {\n return this.manager.remove(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Records the delete date of all given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Records the delete date of a given entity.\n */\n softRemove<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Records the delete date of one or many given entities.\n */\n softRemove<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.softRemove<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\n }\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options: SaveOptions & { reload: false }): Promise<T[]>;\n\n /**\n * Recovers all given entities in the database.\n */\n recover<T extends DeepPartial<Entity>>(entities: T[], options?: SaveOptions): Promise<(T & Entity)[]>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options: SaveOptions & { reload: false }): Promise<T>;\n\n /**\n * Recovers a given entity in the database.\n */\n recover<T extends DeepPartial<Entity>>(entity: T, options?: SaveOptions): Promise<T & Entity>;\n\n /**\n * Recovers one or many given entities.\n */\n recover<T extends DeepPartial<Entity>>(entityOrEntities: T|T[], options?: SaveOptions): Promise<T|T[]> {\n return this.manager.recover<Entity, T>(this.metadata.target as any, entityOrEntities as any, options);\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 insert(entity: QueryDeepPartialEntity<Entity>|(QueryDeepPartialEntity<Entity>[])): Promise<InsertResult> {\n return this.manager.insert(this.metadata.target as any, 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 update(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>, partialEntity: QueryDeepPartialEntity<Entity>): Promise<UpdateResult> {\n return this.manager.update(this.metadata.target as any, criteria as any, 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 upsert(\n entityOrEntities: QueryDeepPartialEntity<Entity> | (QueryDeepPartialEntity<Entity>[]),\n conflictPathsOrOptions: string[] | UpsertOptions<Entity>): Promise<InsertResult> {\n return this.manager.upsert(this.metadata.target as any, entityOrEntities, conflictPathsOrOptions);\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike save 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 delete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<DeleteResult> {\n return this.manager.delete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Records the delete date of entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n softDelete(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.softDelete(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Restores entities by a given criteria.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient SOFT-DELETE query.\n * Does not check if entity exist in the database.\n */\n restore(criteria: string|string[]|number|number[]|Date|Date[]|ObjectID|ObjectID[]|FindConditions<Entity>): Promise<UpdateResult> {\n return this.manager.restore(this.metadata.target as any, criteria as any);\n }\n\n /**\n * Counts entities that match given options.\n */\n count(options?: FindManyOptions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given conditions.\n */\n count(conditions?: FindConditions<Entity>): Promise<number>;\n\n /**\n * Counts entities that match given find options or conditions.\n */\n count(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<number> {\n return this.manager.count(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities that match given options.\n */\n find(options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given conditions.\n */\n find(conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities that match given find options or conditions.\n */\n find(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.find(this.metadata.target as any, optionsOrConditions as any);\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 findAndCount(options?: FindManyOptions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(conditions?: FindConditions<Entity>): Promise<[ Entity[], number ]>;\n\n /**\n * Finds entities that match given find options or conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n findAndCount(optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<[ Entity[], number ]> {\n return this.manager.findAndCount(this.metadata.target as any, optionsOrConditions as any);\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], options?: FindManyOptions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally conditions can be applied.\n */\n findByIds(ids: any[], conditions?: FindConditions<Entity>): Promise<Entity[]>;\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n */\n findByIds(ids: any[], optionsOrConditions?: FindManyOptions<Entity>|FindConditions<Entity>): Promise<Entity[]> {\n return this.manager.findByIds(this.metadata.target as any, ids, optionsOrConditions as any);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOne(options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity|undefined>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOne(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity|undefined> {\n return this.manager.findOne(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\n }\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(id?: string|number|Date|ObjectID, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given options.\n */\n findOneOrFail(options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(conditions?: FindConditions<Entity>, options?: FindOneOptions<Entity>): Promise<Entity>;\n\n /**\n * Finds first entity that matches given conditions.\n */\n findOneOrFail(optionsOrConditions?: string|number|Date|ObjectID|FindOneOptions<Entity>|FindConditions<Entity>, maybeOptions?: FindOneOptions<Entity>): Promise<Entity> {\n return this.manager.findOneOrFail(this.metadata.target as any, optionsOrConditions as any, maybeOptions);\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 query(query: string, parameters?: any[]): Promise<any> {\n return this.manager.query(query, parameters);\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n *\n * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms.\n * @see https://stackoverflow.com/a/5972738/925151\n */\n clear(): Promise<void> {\n return this.manager.clear(this.metadata.target);\n }\n\n /**\n * Increments some column by provided value of the entities matched given conditions.\n */\n increment(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.increment(this.metadata.target, conditions, propertyPath, value);\n }\n\n /**\n * Decrements some column by provided value of the entities matched given conditions.\n */\n decrement(conditions: FindConditions<Entity>, propertyPath: string, value: number | string): Promise<UpdateResult> {\n return this.manager.decrement(this.metadata.target, conditions, propertyPath, value);\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -10,4 +10,9 @@ export interface TableUniqueOptions {
|
|
|
10
10
|
* Columns that contains this constraint.
|
|
11
11
|
*/
|
|
12
12
|
columnNames: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
|
|
15
|
+
* or at the end of a transaction
|
|
16
|
+
*/
|
|
17
|
+
deferrable?: string;
|
|
13
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n}"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/schema-builder/options/TableUniqueOptions.ts"],"names":[],"mappings":"","file":"TableUniqueOptions.js","sourcesContent":["/**\n * Database's table unique constraint options.\n */\nexport interface TableUniqueOptions {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n}"],"sourceRoot":"../.."}
|
|
@@ -12,6 +12,11 @@ export declare class TableUnique {
|
|
|
12
12
|
* Columns that contains this constraint.
|
|
13
13
|
*/
|
|
14
14
|
columnNames: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Set this foreign key constraint as "DEFERRABLE" e.g. check constraints at start
|
|
17
|
+
* or at the end of a transaction
|
|
18
|
+
*/
|
|
19
|
+
deferrable?: string;
|
|
15
20
|
constructor(options: TableUniqueOptions);
|
|
16
21
|
/**
|
|
17
22
|
* Creates a new copy of this constraint with exactly same properties.
|
|
@@ -13,6 +13,7 @@ var TableUnique = /** @class */ (function () {
|
|
|
13
13
|
this.columnNames = [];
|
|
14
14
|
this.name = options.name;
|
|
15
15
|
this.columnNames = options.columnNames;
|
|
16
|
+
this.deferrable = options.deferrable;
|
|
16
17
|
}
|
|
17
18
|
// -------------------------------------------------------------------------
|
|
18
19
|
// Public Methods
|
|
@@ -23,7 +24,8 @@ var TableUnique = /** @class */ (function () {
|
|
|
23
24
|
TableUnique.prototype.clone = function () {
|
|
24
25
|
return new TableUnique({
|
|
25
26
|
name: this.name,
|
|
26
|
-
columnNames: __spreadArray([], __read(this.columnNames), false)
|
|
27
|
+
columnNames: __spreadArray([], __read(this.columnNames), false),
|
|
28
|
+
deferrable: this.deferrable,
|
|
27
29
|
});
|
|
28
30
|
};
|
|
29
31
|
// -------------------------------------------------------------------------
|
|
@@ -35,7 +37,8 @@ var TableUnique = /** @class */ (function () {
|
|
|
35
37
|
TableUnique.create = function (uniqueMetadata) {
|
|
36
38
|
return new TableUnique({
|
|
37
39
|
name: uniqueMetadata.name,
|
|
38
|
-
columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; })
|
|
40
|
+
columnNames: uniqueMetadata.columns.map(function (column) { return column.databaseName; }),
|
|
41
|
+
deferrable: uniqueMetadata.deferrable,
|
|
39
42
|
});
|
|
40
43
|
};
|
|
41
44
|
return TableUnique;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH;
|
|
1
|
+
{"version":3,"sources":["../browser/src/schema-builder/table/TableUnique.ts"],"names":[],"mappings":";AAGA;;GAEG;AACH;IAsBI,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,qBAAY,OAA2B;QAfvC;;WAEG;QACH,gBAAW,GAAa,EAAE,CAAC;QAavB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACzC,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,2BAAK,GAAL;QACI,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,2BAAM,IAAI,CAAC,WAAW,SAAC;YAClC,UAAU,EAAE,IAAI,CAAC,UAAU;SAC9B,CAAC,CAAC;IACP,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACI,kBAAM,GAAb,UAAc,cAA8B;QACxC,OAAO,IAAI,WAAW,CAAqB;YACvC,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,WAAW,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,YAAY,EAAnB,CAAmB,CAAC;YACtE,UAAU,EAAE,cAAc,CAAC,UAAU;SACxC,CAAC,CAAC;IACP,CAAC;IAEL,kBAAC;AAAD,CA9DA,AA8DC,IAAA","file":"TableUnique.js","sourcesContent":["import {TableUniqueOptions} from \"../options/TableUniqueOptions\";\nimport {UniqueMetadata} from \"../../metadata/UniqueMetadata\";\n\n/**\n * Database's table unique constraint stored in this class.\n */\nexport class TableUnique {\n\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Constraint name.\n */\n name?: string;\n\n /**\n * Columns that contains this constraint.\n */\n columnNames: string[] = [];\n\n /**\n * Set this foreign key constraint as \"DEFERRABLE\" e.g. check constraints at start\n * or at the end of a transaction\n */\n deferrable?: string;\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(options: TableUniqueOptions) {\n this.name = options.name;\n this.columnNames = options.columnNames;\n this.deferrable = options.deferrable;\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a new copy of this constraint with exactly same properties.\n */\n clone(): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: this.name,\n columnNames: [...this.columnNames],\n deferrable: this.deferrable,\n });\n }\n\n // -------------------------------------------------------------------------\n // Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates unique from the unique metadata object.\n */\n static create(uniqueMetadata: UniqueMetadata): TableUnique {\n return new TableUnique(<TableUniqueOptions>{\n name: uniqueMetadata.name,\n columnNames: uniqueMetadata.columns.map(column => column.databaseName),\n deferrable: uniqueMetadata.deferrable,\n });\n }\n\n}"],"sourceRoot":"../.."}
|
|
@@ -2,7 +2,7 @@ import { Logger } from "../logger/Logger";
|
|
|
2
2
|
/**
|
|
3
3
|
* Loads all exported classes from the given directory.
|
|
4
4
|
*/
|
|
5
|
-
export declare function importClassesFromDirectories(logger: Logger, directories: string[], formats?: string[]): Function[]
|
|
5
|
+
export declare function importClassesFromDirectories(logger: Logger, directories: string[], formats?: string[]): Promise<Function[]>;
|
|
6
6
|
/**
|
|
7
7
|
* Loads all json files from the given directory.
|
|
8
8
|
*/
|
|
@@ -1,42 +1,66 @@
|
|
|
1
|
+
import { __awaiter, __generator, __read } from "tslib";
|
|
1
2
|
import glob from "glob";
|
|
2
3
|
import { PlatformTools } from "../platform/PlatformTools";
|
|
3
4
|
import { EntitySchema } from "../entity-schema/EntitySchema";
|
|
5
|
+
import { importOrRequireFile } from "./ImportUtils";
|
|
4
6
|
/**
|
|
5
7
|
* Loads all exported classes from the given directory.
|
|
6
8
|
*/
|
|
7
9
|
export function importClassesFromDirectories(logger, directories, formats) {
|
|
8
|
-
if (formats === void 0) { formats = [".js", ".cjs", ".ts"]; }
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
if (formats === void 0) { formats = [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]; }
|
|
11
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12
|
+
function loadFileClasses(exported, allLoaded) {
|
|
13
|
+
if (typeof exported === "function" || exported instanceof EntitySchema) {
|
|
14
|
+
allLoaded.push(exported);
|
|
15
|
+
}
|
|
16
|
+
else if (Array.isArray(exported)) {
|
|
17
|
+
exported.forEach(function (i) { return loadFileClasses(i, allLoaded); });
|
|
18
|
+
}
|
|
19
|
+
else if (typeof exported === "object" && exported !== null) {
|
|
20
|
+
Object.keys(exported).forEach(function (key) { return loadFileClasses(exported[key], allLoaded); });
|
|
21
|
+
}
|
|
22
|
+
return allLoaded;
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
var logLevel, classesNotFoundMessage, classesFoundMessage, allFiles, dirPromises, dirs;
|
|
25
|
+
var _this = this;
|
|
26
|
+
return __generator(this, function (_a) {
|
|
27
|
+
switch (_a.label) {
|
|
28
|
+
case 0:
|
|
29
|
+
logLevel = "info";
|
|
30
|
+
classesNotFoundMessage = "No classes were found using the provided glob pattern: ";
|
|
31
|
+
classesFoundMessage = "All classes found using provided glob pattern";
|
|
32
|
+
allFiles = directories.reduce(function (allDirs, dir) {
|
|
33
|
+
return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));
|
|
34
|
+
}, []);
|
|
35
|
+
if (directories.length > 0 && allFiles.length === 0) {
|
|
36
|
+
logger.log(logLevel, classesNotFoundMessage + " \"" + directories + "\"");
|
|
37
|
+
}
|
|
38
|
+
else if (allFiles.length > 0) {
|
|
39
|
+
logger.log(logLevel, classesFoundMessage + " \"" + directories + "\" : \"" + allFiles + "\"");
|
|
40
|
+
}
|
|
41
|
+
dirPromises = allFiles
|
|
42
|
+
.filter(function (file) {
|
|
43
|
+
var dtsExtension = file.substring(file.length - 5, file.length);
|
|
44
|
+
return formats.indexOf(PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== ".d.ts";
|
|
45
|
+
})
|
|
46
|
+
.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
47
|
+
var _a, importOrRequireResult;
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, importOrRequireFile(PlatformTools.pathResolve(file))];
|
|
51
|
+
case 1:
|
|
52
|
+
_a = __read.apply(void 0, [_b.sent(), 1]), importOrRequireResult = _a[0];
|
|
53
|
+
return [2 /*return*/, importOrRequireResult];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}); });
|
|
57
|
+
return [4 /*yield*/, Promise.all(dirPromises)];
|
|
58
|
+
case 1:
|
|
59
|
+
dirs = _a.sent();
|
|
60
|
+
return [2 /*return*/, loadFileClasses(dirs, [])];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
40
64
|
}
|
|
41
65
|
/**
|
|
42
66
|
* Loads all json files from the given directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/util/DirectoryExportedClassesLoader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAE3D;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/DirectoryExportedClassesLoader.ts"],"names":[],"mappings":";AAAA,OAAO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GAAG,WAAW,CAAC,MAAM,CAAC,UAAC,OAAO,EAAE,GAAG;QAC7C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC,EAAE,EAAc,CAAC,CAAC;IAEnB,OAAO,QAAQ;SACV,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,MAAM,EAA1C,CAA0C,CAAC;SAC1D,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAxC,CAAwC,CAAC,CAAC;AAC/D,CAAC","file":"DirectoryExportedClassesLoader.js","sourcesContent":["import glob from \"glob\";\nimport {PlatformTools} from \"../platform/PlatformTools\";\nimport {EntitySchema} from \"../entity-schema/EntitySchema\";\nimport {Logger} from \"../logger/Logger\";\nimport {importOrRequireFile} from \"./ImportUtils\";\n/**\n * Loads all exported classes from the given directory.\n */\nexport async function importClassesFromDirectories(logger: Logger, directories: string[], formats = [\".js\", \".mjs\", \".cjs\", \".ts\", \".mts\", \".cts\"]): Promise<Function[]> {\n\n const logLevel = \"info\";\n const classesNotFoundMessage = \"No classes were found using the provided glob pattern: \";\n const classesFoundMessage = \"All classes found using provided glob pattern\";\n function loadFileClasses(exported: any, allLoaded: Function[]) {\n if (typeof exported === \"function\" || exported instanceof EntitySchema) {\n allLoaded.push(exported);\n\n } else if (Array.isArray(exported)) {\n exported.forEach((i: any) => loadFileClasses(i, allLoaded));\n\n } else if (typeof exported === \"object\" && exported !== null) {\n Object.keys(exported).forEach(key => loadFileClasses(exported[key], allLoaded));\n\n }\n return allLoaded;\n }\n\n const allFiles = directories.reduce((allDirs, dir) => {\n return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));\n }, [] as string[]);\n\n if (directories.length > 0 && allFiles.length === 0) {\n logger.log(logLevel, `${classesNotFoundMessage} \"${directories}\"`);\n } else if (allFiles.length > 0) {\n logger.log(logLevel, `${classesFoundMessage} \"${directories}\" : \"${allFiles}\"`);\n }\n const dirPromises = allFiles\n .filter(file => {\n const dtsExtension = file.substring(file.length - 5, file.length);\n return formats.indexOf(PlatformTools.pathExtname(file)) !== -1 && dtsExtension !== \".d.ts\";\n })\n .map(async file => {\n const [importOrRequireResult] = await importOrRequireFile(PlatformTools.pathResolve(file));\n return importOrRequireResult;\n });\n\n const dirs = await Promise.all(dirPromises);\n\n return loadFileClasses(dirs, []);\n}\n\n/**\n * Loads all json files from the given directory.\n */\nexport function importJsonsFromDirectories(directories: string[], format = \".json\"): any[] {\n\n const allFiles = directories.reduce((allDirs, dir) => {\n return allDirs.concat(glob.sync(PlatformTools.pathNormalize(dir)));\n }, [] as string[]);\n\n return allFiles\n .filter(file => PlatformTools.pathExtname(file) === format)\n .map(file => require(PlatformTools.pathResolve(file)));\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function importOrRequireFile(filePath: string): Promise<[result: any, moduleType: "esm" | "commonjs"]>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
export function importOrRequireFile(filePath) {
|
|
5
|
+
var _a;
|
|
6
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7
|
+
var tryToImport, tryToRequire, extension, packageJson, isModule;
|
|
8
|
+
var _this = this;
|
|
9
|
+
return __generator(this, function (_b) {
|
|
10
|
+
switch (_b.label) {
|
|
11
|
+
case 0:
|
|
12
|
+
tryToImport = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
13
|
+
return __generator(this, function (_a) {
|
|
14
|
+
switch (_a.label) {
|
|
15
|
+
case 0: return [4 /*yield*/, Function("return filePath => import(filePath)")()(filePath)];
|
|
16
|
+
case 1:
|
|
17
|
+
// `Function` is required to make sure the `import` statement wil stay `import` after
|
|
18
|
+
// transpilation and won't be converted to `require`
|
|
19
|
+
return [2 /*return*/, [_a.sent(), "esm"]];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}); };
|
|
23
|
+
tryToRequire = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
24
|
+
return __generator(this, function (_a) {
|
|
25
|
+
return [2 /*return*/, [require(filePath), "commonjs"]];
|
|
26
|
+
});
|
|
27
|
+
}); };
|
|
28
|
+
extension = filePath.substring(filePath.lastIndexOf(".") + ".".length);
|
|
29
|
+
if (!(extension === "mjs" || extension === "mts")) return [3 /*break*/, 1];
|
|
30
|
+
return [2 /*return*/, tryToImport()];
|
|
31
|
+
case 1:
|
|
32
|
+
if (!(extension === "cjs" || extension === "cts")) return [3 /*break*/, 2];
|
|
33
|
+
return [2 /*return*/, tryToRequire()];
|
|
34
|
+
case 2:
|
|
35
|
+
if (!(extension === "js" || extension === "ts")) return [3 /*break*/, 4];
|
|
36
|
+
return [4 /*yield*/, getNearestPackageJson(filePath)];
|
|
37
|
+
case 3:
|
|
38
|
+
packageJson = _b.sent();
|
|
39
|
+
if (packageJson != null) {
|
|
40
|
+
isModule = ((_a = packageJson) === null || _a === void 0 ? void 0 : _a.type) === "module";
|
|
41
|
+
if (isModule)
|
|
42
|
+
return [2 /*return*/, tryToImport()];
|
|
43
|
+
else
|
|
44
|
+
return [2 /*return*/, tryToRequire()];
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
return [2 /*return*/, tryToRequire()];
|
|
48
|
+
_b.label = 4;
|
|
49
|
+
case 4: return [2 /*return*/, tryToRequire()];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getNearestPackageJson(filePath) {
|
|
55
|
+
return new Promise(function (accept) {
|
|
56
|
+
var currentPath = filePath;
|
|
57
|
+
function searchPackageJson() {
|
|
58
|
+
var nextPath = path.dirname(currentPath);
|
|
59
|
+
if (currentPath === nextPath) // the top of the file tree is reached
|
|
60
|
+
accept(null);
|
|
61
|
+
else {
|
|
62
|
+
currentPath = nextPath;
|
|
63
|
+
var potentialPackageJson_1 = path.join(currentPath, "package.json");
|
|
64
|
+
fs.stat(potentialPackageJson_1, function (err, stats) {
|
|
65
|
+
if (err != null)
|
|
66
|
+
searchPackageJson();
|
|
67
|
+
else if (stats.isFile()) {
|
|
68
|
+
fs.readFile(potentialPackageJson_1, "utf8", function (err, data) {
|
|
69
|
+
if (err != null)
|
|
70
|
+
accept(null);
|
|
71
|
+
else {
|
|
72
|
+
try {
|
|
73
|
+
accept(JSON.parse(data));
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
accept(null);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
searchPackageJson();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
searchPackageJson();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=ImportUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../browser/src/util/ImportUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAgB,mBAAmB,CAAC,QAAgB;;;;;;;;oBAChD,WAAW,GAAG;;;wCAGR,qBAAM,QAAQ,CAAC,qCAAqC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAA;;gCAFzE,qFAAqF;gCACrF,oDAAoD;gCACpD,uBAAQ,SAAiE,EAAE,KAAK,GAAE;;;yBACrF,CAAC;oBACI,YAAY,GAAG;;4BACjB,sBAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAAC;;yBAC1C,CAAC;oBAEI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAA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,IAAI,IAAI;wBACX,iBAAiB,EAAE,CAAC;yBACnB,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;wBACrB,EAAE,CAAC,QAAQ,CAAC,sBAAoB,EAAE,MAAM,EAAE,UAAC,GAAG,EAAE,IAAI;4BAChD,IAAI,GAAG,IAAI,IAAI;gCACX,MAAM,CAAC,IAAI,CAAC,CAAC;iCACZ;gCACD,IAAI;oCACA,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;iCAC5B;gCAAC,OAAO,GAAG,EAAE;oCACV,MAAM,CAAC,IAAI,CAAC,CAAC;iCAChB;6BACJ;wBACL,CAAC,CAAC,CAAC;qBACN;;wBACG,iBAAiB,EAAE,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QAED,iBAAiB,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC","file":"ImportUtils.js","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nexport async function importOrRequireFile(filePath: string): Promise<[result: any, moduleType: \"esm\" | \"commonjs\"]> {\n const tryToImport = async (): Promise<[any, \"esm\"]> => {\n // `Function` is required to make sure the `import` statement wil stay `import` after\n // transpilation and won't be converted to `require`\n return [await Function(\"return filePath => import(filePath)\")()(filePath), \"esm\"];\n };\n const tryToRequire = async (): Promise<[any, \"commonjs\"]> => {\n return [require(filePath), \"commonjs\"];\n };\n\n const extension = filePath.substring(filePath.lastIndexOf(\".\") + \".\".length);\n\n if (extension === \"mjs\" || extension === \"mts\")\n return tryToImport();\n else if (extension === \"cjs\" || extension === \"cts\")\n return tryToRequire();\n else if (extension === \"js\" || extension === \"ts\") {\n const packageJson = await getNearestPackageJson(filePath);\n\n if (packageJson != null) {\n const isModule = (packageJson as any)?.type === \"module\";\n\n if (isModule)\n return tryToImport();\n else\n return tryToRequire();\n } else\n return tryToRequire();\n }\n\n return tryToRequire();\n}\n\nfunction getNearestPackageJson(filePath: string): Promise<object | null> {\n return new Promise((accept) => {\n let currentPath = filePath;\n\n function searchPackageJson() {\n const nextPath = path.dirname(currentPath);\n\n if (currentPath === nextPath) // the top of the file tree is reached\n accept(null);\n else {\n currentPath = nextPath;\n const potentialPackageJson = path.join(currentPath, \"package.json\");\n\n fs.stat(potentialPackageJson, (err, stats) => {\n if (err != null)\n searchPackageJson();\n else if (stats.isFile()) {\n fs.readFile(potentialPackageJson, \"utf8\", (err, data) => {\n if (err != null)\n accept(null);\n else {\n try {\n accept(JSON.parse(data));\n } catch (err) {\n accept(null);\n }\n }\n });\n } else\n searchPackageJson();\n });\n }\n }\n\n searchPackageJson();\n });\n}\n"],"sourceRoot":".."}
|