typeorm 0.3.5-dev.ec6c119 → 0.3.6-dev.4687be8
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 +3 -10
- package/browser/cli-ts-node-commonjs.d.ts +1 -1
- package/browser/cli-ts-node-commonjs.js +2 -1
- package/browser/cli-ts-node-commonjs.js.map +1 -1
- package/browser/cli-ts-node-esm.d.ts +2 -2
- package/browser/cli-ts-node-esm.js +19 -2
- package/browser/cli-ts-node-esm.js.map +1 -1
- package/browser/common/DeepPartial.d.ts +2 -2
- package/browser/common/DeepPartial.js.map +1 -1
- package/browser/data-source/BaseDataSourceOptions.d.ts +1 -2
- package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
- package/browser/data-source/DataSource.js +2 -5
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/decorator/options/ColumnOptions.d.ts +1 -0
- package/browser/decorator/options/ColumnOptions.js.map +1 -1
- package/browser/driver/DriverUtils.d.ts +1 -0
- package/browser/driver/DriverUtils.js +3 -0
- package/browser/driver/DriverUtils.js.map +1 -1
- package/browser/driver/cordova/CordovaDriver.js +1 -1
- package/browser/driver/cordova/CordovaDriver.js.map +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js +2 -2
- package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/browser/driver/expo/ExpoDriver.js +1 -1
- package/browser/driver/expo/ExpoDriver.js.map +1 -1
- package/browser/driver/expo/ExpoQueryRunner.js +2 -2
- package/browser/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/browser/driver/nativescript/NativescriptDriver.js +1 -1
- package/browser/driver/nativescript/NativescriptDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.js +1 -4
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/react-native/ReactNativeDriver.js +1 -1
- package/browser/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/browser/driver/sqlite/SqliteDriver.js +3 -3
- package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +2 -2
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqljs/SqljsDriver.js +1 -1
- package/browser/driver/sqljs/SqljsDriver.js.map +1 -1
- package/browser/find-options/FindOneOptions.d.ts +1 -1
- package/browser/find-options/FindOneOptions.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.d.ts +2 -1
- package/browser/find-options/FindOptionsUtils.js +2 -1
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/index.d.ts +4 -0
- package/browser/index.js +3 -0
- package/browser/index.js.map +1 -1
- package/browser/persistence/EntityPersistExecutor.js +12 -1
- package/browser/persistence/EntityPersistExecutor.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.d.ts +9 -0
- package/browser/query-builder/InsertQueryBuilder.js +4 -5
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/QueryExpressionMap.d.ts +1 -1
- package/browser/query-builder/QueryExpressionMap.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +11 -2
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/cli-ts-node-commonjs.d.ts +1 -1
- package/cli-ts-node-commonjs.js +2 -1
- package/cli-ts-node-commonjs.js.map +1 -1
- package/cli-ts-node-esm.d.ts +2 -2
- package/cli-ts-node-esm.js +19 -2
- package/cli-ts-node-esm.js.map +1 -1
- package/commands/CommandUtils.js +1 -1
- package/commands/CommandUtils.js.map +1 -1
- package/commands/InitCommand.js +1 -1
- package/commands/InitCommand.js.map +1 -1
- package/common/DeepPartial.d.ts +2 -2
- package/common/DeepPartial.js.map +1 -1
- package/data-source/BaseDataSourceOptions.d.ts +1 -2
- package/data-source/BaseDataSourceOptions.js.map +1 -1
- package/data-source/DataSource.js +17 -20
- package/data-source/DataSource.js.map +1 -1
- package/decorator/options/ColumnOptions.d.ts +1 -0
- package/decorator/options/ColumnOptions.js.map +1 -1
- package/driver/DriverUtils.d.ts +1 -0
- package/driver/DriverUtils.js +3 -0
- package/driver/DriverUtils.js.map +1 -1
- package/driver/cordova/CordovaDriver.js +1 -1
- package/driver/cordova/CordovaDriver.js.map +1 -1
- package/driver/cordova/CordovaQueryRunner.js +2 -2
- package/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/driver/expo/ExpoDriver.js +1 -1
- package/driver/expo/ExpoDriver.js.map +1 -1
- package/driver/expo/ExpoQueryRunner.js +2 -2
- package/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/driver/nativescript/NativescriptDriver.js +1 -1
- package/driver/nativescript/NativescriptDriver.js.map +1 -1
- package/driver/postgres/PostgresDriver.js +1 -4
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/react-native/ReactNativeDriver.js +1 -1
- package/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/driver/sqlite/SqliteDriver.js +3 -3
- package/driver/sqlite/SqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +2 -2
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqljs/SqljsDriver.js +1 -1
- package/driver/sqljs/SqljsDriver.js.map +1 -1
- package/find-options/FindOneOptions.d.ts +1 -1
- package/find-options/FindOneOptions.js.map +1 -1
- package/find-options/FindOptionsUtils.d.ts +2 -1
- package/find-options/FindOptionsUtils.js +2 -1
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/index.mjs +6 -0
- package/package.json +1 -1
- package/persistence/EntityPersistExecutor.js +12 -1
- package/persistence/EntityPersistExecutor.js.map +1 -1
- package/query-builder/InsertQueryBuilder.d.ts +9 -0
- package/query-builder/InsertQueryBuilder.js +4 -5
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/QueryExpressionMap.d.ts +1 -1
- package/query-builder/QueryExpressionMap.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +1 -1
- package/query-builder/SelectQueryBuilder.js +11 -2
- package/query-builder/SelectQueryBuilder.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAA;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAS1C,MAAM,OAAO,WAAY,SAAQ,oBAAoB;IAIjD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB;QAC9B,KAAK,CAAC,UAAU,CAAC,CAAA;QAEjB,8EAA8E;QAC9E,uEAAuE;QACvE,IACI,IAAI,CAAC,OAAO,CAAC,QAAQ;YACrB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ;YACtB,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAChC;YACE,MAAM,IAAI,uBAAuB,CAAC,8BAA8B,CAAC,CAAA;SACpE;QAED,sBAAsB;QACtB,IAAI,CAAC,gBAAgB,EAAE,CAAA;IAC3B,CAAC;IAED,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,OAAO;QACT,IAAI,CAAC,kBAAkB,GAAG,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,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M,CAAC,QAAQ,KAAK,UAAU,CAAA;QAClE,MAAM,MAAM,GAAG,eAAe;YAC1B,CAAC,CAAC,IAAI,CAAC,MAAM;YACb,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QACjD,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACjC,IAAI,CAAC,kBAAkB,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;SAC1D;aAAM;YACH,IAAI,CAAC,kBAAkB,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAA;SAClD;QAED,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;QAEzD,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAClC,CAAC;IAED;;OAEG;IACO,gBAAgB;QACtB,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS,EAAE;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAA;YAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;SACvB;aAAM;YACH,IAAI;gBACA,MAAM,MAAM,GACR,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;aACvB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,8BAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;aAC/D;SACJ;IACL,CAAC;CACJ","file":"SqljsDriver.js","sourcesContent":["import { AbstractSqliteDriver } from \"../sqlite-abstract/AbstractSqliteDriver\"\nimport { SqljsConnectionOptions } from \"./SqljsConnectionOptions\"\nimport { SqljsQueryRunner } from \"./SqljsQueryRunner\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport { DriverOptionNotSetError } from \"../../error/DriverOptionNotSetError\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { TypeORMError } from \"../../error\"\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any\n localforage: any\n}\ndeclare let window: Window\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource) {\n super(connection)\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (\n this.options.autoSave &&\n !this.options.location &&\n !this.options.autoSaveCallback\n ) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`)\n }\n\n // load sql.js package\n this.loadDependencies()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection()\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined\n this.databaseConnection.close()\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner) this.queryRunner = new SqljsQueryRunner(this)\n\n return this.queryRunner\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(\n fileNameOrLocalStorageOrData: string | Uint8Array,\n checkIfFileOrLocalStorageExists: boolean = true,\n ): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(\n fileNameOrLocalStorageOrData,\n )\n return this.createDatabaseConnectionWithImport(database)\n } else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(\n `File ${fileNameOrLocalStorageOrData} does not exist`,\n )\n } else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport()\n }\n } else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(\n fileNameOrLocalStorageOrData,\n )\n } else {\n throw new TypeORMError(\n `localforage is not defined - please import localforage.js into your site`,\n )\n }\n } else {\n localStorageContent =\n PlatformTools.getGlobalVariable().localStorage.getItem(\n fileNameOrLocalStorageOrData,\n )\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(\n JSON.parse(localStorageContent),\n )\n } else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(\n `File ${fileNameOrLocalStorageOrData} does not exist`,\n )\n } else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport()\n }\n }\n } else {\n return this.createDatabaseConnectionWithImport(\n fileNameOrLocalStorageOrData,\n )\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(\n `No location is set, specify a location parameter or add the location option to your configuration`,\n )\n }\n\n let path = \"\"\n if (location) {\n path = location\n } else if (this.options.location) {\n path = this.options.location\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export())\n await PlatformTools.writeFile(path, content)\n } catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`)\n }\n } else {\n const database: Uint8Array = this.databaseConnection.export()\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database)\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(\n path,\n JSON.stringify(databaseArray),\n )\n } else {\n throw new TypeORMError(\n `localforage is not defined - please import localforage.js into your site`,\n )\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(\n path,\n JSON.stringify(databaseArray),\n )\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export())\n } else {\n await this.save()\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export()\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce(\n (map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (\n generatedColumn.isPrimary &&\n generatedColumn.generationStrategy === \"increment\"\n ) {\n const query = \"SELECT last_insert_rowid()\"\n try {\n let result = this.databaseConnection.exec(query)\n this.connection.logger.logQuery(query)\n return OrmUtils.mergeDeep(\n map,\n generatedColumn.createValueMap(\n result[0].values[0][0],\n ),\n )\n } catch (e) {\n this.connection.logger.logQueryError(e, query, [])\n }\n }\n\n return map\n },\n {} as ObjectLiteral,\n )\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false)\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database)\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(\n database?: Uint8Array,\n ): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\"\n const sqlite = isLegacyVersion\n ? this.sqlite\n : await this.sqlite(this.options.sqlJsConfig)\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database)\n } else {\n this.databaseConnection = new sqlite.Database()\n }\n\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON;`)\n\n return this.databaseConnection\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL\n this.sqlite = sqlite\n } else {\n try {\n const sqlite =\n this.options.driver || PlatformTools.load(\"sql.js\")\n this.sqlite = sqlite\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\")\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAA;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAA;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;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B;QACtB,IAAI,aAAa,CAAC,IAAI,KAAK,SAAS,EAAE;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,GAAG,CAAA;YAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;SACvB;aAAM;YACH,IAAI;gBACA,MAAM,MAAM,GACR,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;aACvB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,8BAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;aAC/D;SACJ;IACL,CAAC;CACJ","file":"SqljsDriver.js","sourcesContent":["import { AbstractSqliteDriver } from \"../sqlite-abstract/AbstractSqliteDriver\"\nimport { SqljsConnectionOptions } from \"./SqljsConnectionOptions\"\nimport { SqljsQueryRunner } from \"./SqljsQueryRunner\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport { DriverOptionNotSetError } from \"../../error/DriverOptionNotSetError\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { TypeORMError } from \"../../error\"\n\n// This is needed to satisfy the typescript compiler.\ninterface Window {\n SQL: any\n localforage: any\n}\ndeclare let window: Window\n\nexport class SqljsDriver extends AbstractSqliteDriver {\n // The driver specific options.\n options: SqljsConnectionOptions\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection: DataSource) {\n super(connection)\n\n // If autoSave is enabled by user, location or autoSaveCallback have to be set\n // because either autoSave saves to location or calls autoSaveCallback.\n if (\n this.options.autoSave &&\n !this.options.location &&\n !this.options.autoSaveCallback\n ) {\n throw new DriverOptionNotSetError(`location or autoSaveCallback`)\n }\n\n // load sql.js package\n this.loadDependencies()\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n */\n async connect(): Promise<void> {\n this.databaseConnection = await this.createDatabaseConnection()\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n this.queryRunner = undefined\n this.databaseConnection.close()\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n if (!this.queryRunner) this.queryRunner = new SqljsQueryRunner(this)\n\n return this.queryRunner\n }\n\n /**\n * Loads a database from a given file (Node.js), local storage key (browser) or array.\n * This will delete the current database!\n */\n async load(\n fileNameOrLocalStorageOrData: string | Uint8Array,\n checkIfFileOrLocalStorageExists: boolean = true,\n ): Promise<any> {\n if (typeof fileNameOrLocalStorageOrData === \"string\") {\n // content has to be loaded\n if (PlatformTools.type === \"node\") {\n // Node.js\n // fileNameOrLocalStorageOrData should be a path to the file\n if (PlatformTools.fileExist(fileNameOrLocalStorageOrData)) {\n const database = PlatformTools.readFileSync(\n fileNameOrLocalStorageOrData,\n )\n return this.createDatabaseConnectionWithImport(database)\n } else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(\n `File ${fileNameOrLocalStorageOrData} does not exist`,\n )\n } else {\n // File doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing an existing file.\n // File will be written on first write operation.\n return this.createDatabaseConnectionWithImport()\n }\n } else {\n // browser\n // fileNameOrLocalStorageOrData should be a local storage / indexedDB key\n let localStorageContent = null\n if (this.options.useLocalForage) {\n if (window.localforage) {\n localStorageContent = await window.localforage.getItem(\n fileNameOrLocalStorageOrData,\n )\n } else {\n throw new TypeORMError(\n `localforage is not defined - please import localforage.js into your site`,\n )\n }\n } else {\n localStorageContent =\n PlatformTools.getGlobalVariable().localStorage.getItem(\n fileNameOrLocalStorageOrData,\n )\n }\n\n if (localStorageContent != null) {\n // localStorage value exists.\n return this.createDatabaseConnectionWithImport(\n JSON.parse(localStorageContent),\n )\n } else if (checkIfFileOrLocalStorageExists) {\n throw new TypeORMError(\n `File ${fileNameOrLocalStorageOrData} does not exist`,\n )\n } else {\n // localStorage value doesn't exist and checkIfFileOrLocalStorageExists is set to false.\n // Therefore open a database without importing anything.\n // localStorage value will be written on first write operation.\n return this.createDatabaseConnectionWithImport()\n }\n }\n } else {\n return this.createDatabaseConnectionWithImport(\n fileNameOrLocalStorageOrData,\n )\n }\n }\n\n /**\n * Saved the current database to the given file (Node.js), local storage key (browser) or\n * indexedDB key (browser with enabled useLocalForage option).\n * If no location path is given, the location path in the options (if specified) will be used.\n */\n async save(location?: string) {\n if (!location && !this.options.location) {\n throw new TypeORMError(\n `No location is set, specify a location parameter or add the location option to your configuration`,\n )\n }\n\n let path = \"\"\n if (location) {\n path = location\n } else if (this.options.location) {\n path = this.options.location\n }\n\n if (PlatformTools.type === \"node\") {\n try {\n const content = Buffer.from(this.databaseConnection.export())\n await PlatformTools.writeFile(path, content)\n } catch (e) {\n throw new TypeORMError(`Could not save database, error: ${e}`)\n }\n } else {\n const database: Uint8Array = this.databaseConnection.export()\n // convert Uint8Array to number array to improve local-storage storage\n const databaseArray = [].slice.call(database)\n if (this.options.useLocalForage) {\n if (window.localforage) {\n await window.localforage.setItem(\n path,\n JSON.stringify(databaseArray),\n )\n } else {\n throw new TypeORMError(\n `localforage is not defined - please import localforage.js into your site`,\n )\n }\n } else {\n PlatformTools.getGlobalVariable().localStorage.setItem(\n path,\n JSON.stringify(databaseArray),\n )\n }\n }\n }\n\n /**\n * This gets called by the QueryRunner when a change to the database is made.\n * If a custom autoSaveCallback is specified, it get's called with the database as Uint8Array,\n * otherwise the save method is called which saves it to file (Node.js), local storage (browser)\n * or indexedDB (browser with enabled useLocalForage option).\n */\n async autoSave() {\n if (this.options.autoSave) {\n if (this.options.autoSaveCallback) {\n await this.options.autoSaveCallback(this.export())\n } else {\n await this.save()\n }\n }\n }\n\n /**\n * Returns the current database as Uint8Array.\n */\n export(): Uint8Array {\n return this.databaseConnection.export()\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: any) {\n const generatedMap = metadata.generatedColumns.reduce(\n (map, generatedColumn) => {\n // seems to be the only way to get the inserted id, see https://github.com/kripken/sql.js/issues/77\n if (\n generatedColumn.isPrimary &&\n generatedColumn.generationStrategy === \"increment\"\n ) {\n const query = \"SELECT last_insert_rowid()\"\n try {\n let result = this.databaseConnection.exec(query)\n this.connection.logger.logQuery(query)\n return OrmUtils.mergeDeep(\n map,\n generatedColumn.createValueMap(\n result[0].values[0][0],\n ),\n )\n } catch (e) {\n this.connection.logger.logQueryError(e, query, [])\n }\n }\n\n return map\n },\n {} as ObjectLiteral,\n )\n\n return Object.keys(generatedMap).length > 0 ? generatedMap : undefined\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates connection with the database.\n * If the location option is set, the database is loaded first.\n */\n protected createDatabaseConnection(): Promise<any> {\n if (this.options.location) {\n return this.load(this.options.location, false)\n }\n\n return this.createDatabaseConnectionWithImport(this.options.database)\n }\n\n /**\n * Creates connection with an optional database.\n * If database is specified it is loaded, otherwise a new empty database is created.\n */\n protected async createDatabaseConnectionWithImport(\n database?: Uint8Array,\n ): Promise<any> {\n // sql.js < 1.0 exposes an object with a `Database` method.\n const isLegacyVersion = typeof this.sqlite.Database === \"function\"\n const sqlite = isLegacyVersion\n ? this.sqlite\n : await this.sqlite(this.options.sqlJsConfig)\n if (database && database.length > 0) {\n this.databaseConnection = new sqlite.Database(database)\n } else {\n this.databaseConnection = new sqlite.Database()\n }\n\n this.databaseConnection.exec(`PRAGMA foreign_keys = ON`)\n\n return this.databaseConnection\n }\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n if (PlatformTools.type === \"browser\") {\n const sqlite = this.options.driver || window.SQL\n this.sqlite = sqlite\n } else {\n try {\n const sqlite =\n this.options.driver || PlatformTools.load(\"sql.js\")\n this.sqlite = sqlite\n } catch (e) {\n throw new DriverPackageNotInstalledError(\"sql.js\", \"sql.js\")\n }\n }\n }\n}\n"],"sourceRoot":"../.."}
|
|
@@ -59,7 +59,7 @@ export interface FindOneOptions<Entity = any> {
|
|
|
59
59
|
mode: "optimistic";
|
|
60
60
|
version: number | Date;
|
|
61
61
|
} | {
|
|
62
|
-
mode: "pessimistic_read" | "pessimistic_write" | "dirty_read" | "pessimistic_partial_write" | "pessimistic_write_or_fail" | "for_no_key_update";
|
|
62
|
+
mode: "pessimistic_read" | "pessimistic_write" | "dirty_read" | "pessimistic_partial_write" | "pessimistic_write_or_fail" | "for_no_key_update" | "for_key_share";
|
|
63
63
|
tables?: string[];
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/find-options/FindOneOptions.ts"],"names":[],"mappings":"","file":"FindOneOptions.js","sourcesContent":["import { JoinOptions } from \"./JoinOptions\"\nimport { FindOptionsWhere } from \"./FindOptionsWhere\"\nimport {\n FindOptionsSelect,\n FindOptionsSelectByString,\n} from \"./FindOptionsSelect\"\nimport {\n FindOptionsRelationByString,\n FindOptionsRelations,\n} from \"./FindOptionsRelations\"\nimport { FindOptionsOrder } from \"./FindOptionsOrder\"\n\n/**\n * Defines a special criteria to find specific entity.\n */\nexport interface FindOneOptions<Entity = any> {\n /**\n * Adds a comment with the supplied string in the generated query. This is\n * helpful for debugging purposes, such as finding a specific query in the\n * database server's logs, or for categorization using an APM product.\n */\n comment?: string\n\n /**\n * Specifies what columns should be retrieved.\n */\n select?: FindOptionsSelect<Entity> | FindOptionsSelectByString<Entity>\n\n /**\n * Simple condition that should be applied to match entities.\n */\n where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>\n\n /**\n * Indicates what relations of entity should be loaded (simplified left join form).\n */\n relations?: FindOptionsRelations<Entity> | FindOptionsRelationByString\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but default can be customized in connection options.\n */\n relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Specifies what relations should be loaded.\n *\n * @deprecated\n */\n join?: JoinOptions\n\n /**\n * Order, in which entities should be ordered.\n */\n order?: FindOptionsOrder<Entity>\n\n /**\n * Enables or disables query result caching.\n */\n cache?: boolean | number | { id: any; milliseconds: number }\n\n /**\n * Indicates what locking mode should be used.\n *\n * Note: For lock tables, you must specify the table names and not the relation names\n */\n lock?:\n | { mode: \"optimistic\"; version: number | Date }\n | {\n mode:\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n tables?: string[]\n }\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n */\n withDeleted?: boolean\n\n /**\n * If sets to true then loads all relation ids of the entity and maps them into relation values (not relation objects).\n * If array of strings is given then loads only relation ids of the given properties.\n */\n loadRelationIds?:\n | boolean\n | { relations?: string[]; disableMixedMap?: boolean } // todo: extract options into separate interface, reuse\n\n /**\n * Indicates if eager relations should be loaded or not.\n * By default, they are loaded when find methods are used.\n */\n loadEagerRelations?: boolean\n\n /**\n * If this is set to true, SELECT query in a `find` method will be executed in a transaction.\n */\n transaction?: boolean\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/find-options/FindOneOptions.ts"],"names":[],"mappings":"","file":"FindOneOptions.js","sourcesContent":["import { JoinOptions } from \"./JoinOptions\"\nimport { FindOptionsWhere } from \"./FindOptionsWhere\"\nimport {\n FindOptionsSelect,\n FindOptionsSelectByString,\n} from \"./FindOptionsSelect\"\nimport {\n FindOptionsRelationByString,\n FindOptionsRelations,\n} from \"./FindOptionsRelations\"\nimport { FindOptionsOrder } from \"./FindOptionsOrder\"\n\n/**\n * Defines a special criteria to find specific entity.\n */\nexport interface FindOneOptions<Entity = any> {\n /**\n * Adds a comment with the supplied string in the generated query. This is\n * helpful for debugging purposes, such as finding a specific query in the\n * database server's logs, or for categorization using an APM product.\n */\n comment?: string\n\n /**\n * Specifies what columns should be retrieved.\n */\n select?: FindOptionsSelect<Entity> | FindOptionsSelectByString<Entity>\n\n /**\n * Simple condition that should be applied to match entities.\n */\n where?: FindOptionsWhere<Entity>[] | FindOptionsWhere<Entity>\n\n /**\n * Indicates what relations of entity should be loaded (simplified left join form).\n */\n relations?: FindOptionsRelations<Entity> | FindOptionsRelationByString\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but default can be customized in connection options.\n */\n relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Specifies what relations should be loaded.\n *\n * @deprecated\n */\n join?: JoinOptions\n\n /**\n * Order, in which entities should be ordered.\n */\n order?: FindOptionsOrder<Entity>\n\n /**\n * Enables or disables query result caching.\n */\n cache?: boolean | number | { id: any; milliseconds: number }\n\n /**\n * Indicates what locking mode should be used.\n *\n * Note: For lock tables, you must specify the table names and not the relation names\n */\n lock?:\n | { mode: \"optimistic\"; version: number | Date }\n | {\n mode:\n | \"pessimistic_read\"\n | \"pessimistic_write\"\n | \"dirty_read\"\n | \"pessimistic_partial_write\"\n | \"pessimistic_write_or_fail\"\n | \"for_no_key_update\"\n | \"for_key_share\"\n tables?: string[]\n }\n\n /**\n * Indicates if soft-deleted rows should be included in entity result.\n */\n withDeleted?: boolean\n\n /**\n * If sets to true then loads all relation ids of the entity and maps them into relation values (not relation objects).\n * If array of strings is given then loads only relation ids of the given properties.\n */\n loadRelationIds?:\n | boolean\n | { relations?: string[]; disableMixedMap?: boolean } // todo: extract options into separate interface, reuse\n\n /**\n * Indicates if eager relations should be loaded or not.\n * By default, they are loaded when find methods are used.\n */\n loadEagerRelations?: boolean\n\n /**\n * If this is set to true, SELECT query in a `find` method will be executed in a transaction.\n */\n transaction?: boolean\n}\n"],"sourceRoot":".."}
|
|
@@ -123,7 +123,8 @@ export declare class FindOptionsUtils {
|
|
|
123
123
|
options.lock.mode === "dirty_read" ||
|
|
124
124
|
options.lock.mode === "pessimistic_partial_write" ||
|
|
125
125
|
options.lock.mode === "pessimistic_write_or_fail" ||
|
|
126
|
-
options.lock.mode === "for_no_key_update"
|
|
126
|
+
options.lock.mode === "for_no_key_update" ||
|
|
127
|
+
options.lock.mode === "for_key_share"
|
|
127
128
|
) {
|
|
128
129
|
const tableNames = options.lock.tables ? options.lock.tables.map((table) => {
|
|
129
130
|
const tableAlias = qb.expressionMap.aliases.find((alias) => {
|
|
@@ -161,7 +161,8 @@ export class FindOptionsUtils {
|
|
|
161
161
|
options.lock.mode === "dirty_read" ||
|
|
162
162
|
options.lock.mode === "pessimistic_partial_write" ||
|
|
163
163
|
options.lock.mode === "pessimistic_write_or_fail" ||
|
|
164
|
-
options.lock.mode === "for_no_key_update"
|
|
164
|
+
options.lock.mode === "for_no_key_update" ||
|
|
165
|
+
options.lock.mode === "for_key_share"
|
|
165
166
|
) {
|
|
166
167
|
const tableNames = options.lock.tables ? options.lock.tables.map((table) => {
|
|
167
168
|
const tableAlias = qb.expressionMap.aliases.find((alias) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/find-options/FindOptionsUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAA;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CA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,aAAa,KAAK,SAAS;oBAChC,IAAI,CAAC,SAAS,KAAK,MAAM;oBACzB,IAAI,CAAC,gBAAgB;wBACjB,GAAG,KAAK,IAAI,QAAQ,CAAC,YAAY,EAAE,EACzC;oBACE,SAAQ;iBACX;gBACD,OAAO,GAAG,KAAK,CAAA;gBACf,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;gBAC/B,MAAK;aACR;YAED,IAAI,OAAO,EAAE;gBACT,EAAE,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,GAAG,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;aAClE;YAED,qDAAqD;YACrD,oEAAoE;YACpE,IAAI,SAAS,GAAG,IAAI,CAAA;YACpB,KAAK,MAAM,MAAM,IAAI,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE;gBAC3C,IACI,MAAM,CAAC,SAAS,KAAK,SAAS;oBAC9B,MAAM,CAAC,OAAO,KAAK,SAAS;oBAC5B,MAAM,CAAC,SAAS,KAAK,aAAa,EACpC;oBACE,SAAQ;iBACX;gBACD,SAAS,GAAG,KAAK,CAAA;gBACjB,MAAK;aACR;YAED,IAAI,SAAS,EAAE;gBACX,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;aAC9B;YAED,uCAAuC;YACvC,IAAI,CAAC,kBAAkB,CACnB,EAAE,EACF,aAAa,EACb,QAAQ,CAAC,qBAAqB,CACjC,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","file":"FindOptionsUtils.js","sourcesContent":["import { FindManyOptions } from \"./FindManyOptions\"\nimport { FindOneOptions } from \"./FindOneOptions\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { FindRelationsNotFoundError } from \"../error/FindRelationsNotFoundError\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { FindTreeOptions } from \"./FindTreeOptions\"\n\n/**\n * Utilities to work with FindOptions.\n */\nexport class FindOptionsUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if given object is really instance of FindOneOptions interface.\n */\n static isFindOneOptions<Entity = any>(\n obj: any,\n ): obj is FindOneOptions<Entity> {\n const possibleOptions: FindOneOptions<Entity> = obj\n return (\n possibleOptions &&\n (Array.isArray(possibleOptions.select) ||\n Array.isArray(possibleOptions.relations) ||\n typeof possibleOptions.select === \"object\" ||\n typeof possibleOptions.relations === \"object\" ||\n typeof possibleOptions.where === \"object\" ||\n // typeof possibleOptions.where === \"string\" ||\n typeof possibleOptions.join === \"object\" ||\n typeof possibleOptions.order === \"object\" ||\n typeof possibleOptions.cache === \"object\" ||\n typeof possibleOptions.cache === \"boolean\" ||\n typeof possibleOptions.cache === \"number\" ||\n typeof possibleOptions.comment === \"string\" ||\n typeof possibleOptions.lock === \"object\" ||\n typeof possibleOptions.loadRelationIds === \"object\" ||\n typeof possibleOptions.loadRelationIds === \"boolean\" ||\n typeof possibleOptions.loadEagerRelations === \"boolean\" ||\n typeof possibleOptions.withDeleted === \"boolean\" ||\n typeof possibleOptions.relationLoadStrategy === \"string\" ||\n typeof possibleOptions.transaction === \"boolean\")\n )\n }\n\n /**\n * Checks if given object is really instance of FindManyOptions interface.\n */\n static isFindManyOptions<Entity = any>(\n obj: any,\n ): obj is FindManyOptions<Entity> {\n const possibleOptions: FindManyOptions<Entity> = obj\n return (\n possibleOptions &&\n (this.isFindOneOptions(possibleOptions) ||\n typeof (possibleOptions as FindManyOptions<any>).skip ===\n \"number\" ||\n typeof (possibleOptions as FindManyOptions<any>).take ===\n \"number\" ||\n typeof (possibleOptions as FindManyOptions<any>).skip ===\n \"string\" ||\n typeof (possibleOptions as FindManyOptions<any>).take ===\n \"string\")\n )\n }\n\n /**\n * Checks if given object is really instance of FindOptions interface.\n */\n static extractFindManyOptionsAlias(object: any): string | undefined {\n if (this.isFindManyOptions(object) && object.join)\n return object.join.alias\n\n return undefined\n }\n\n /**\n * Applies give find many options to the given query builder.\n\n static applyFindManyOptionsOrConditionsToQueryBuilder<T>(qb: SelectQueryBuilder<T>, options: FindManyOptions<T>|Partial<T>|undefined): SelectQueryBuilder<T> {\n if (this.isFindManyOptions(options))\n return this.applyOptionsToQueryBuilder(qb, options);\n\n if (options)\n return qb.where(options);\n\n return qb;\n }*/\n\n /**\n * Applies give find options to the given query builder.\n\n static applyOptionsToQueryBuilder<T>(qb: SelectQueryBuilder<T>, options: FindOneOptions<T>|FindManyOptions<T>|undefined): SelectQueryBuilder<T> {\n\n // if options are not set then simply return query builder. This is made for simplicity of usage.\n if (!options || (!this.isFindOneOptions(options) && !this.isFindManyOptions(options)))\n return qb;\n\n if (options.transaction === true) {\n qb.expressionMap.useTransaction = true;\n }\n\n if (!qb.expressionMap.mainAlias || !qb.expressionMap.mainAlias.hasMetadata)\n return qb;\n\n const metadata = qb.expressionMap.mainAlias!.metadata;\n\n // apply all options from FindOptions\n if (options.comment) {\n qb.comment(options.comment);\n }\n\n if (options.withDeleted) {\n qb.withDeleted();\n }\n\n if (options.select) {\n qb.select([]);\n options.select.forEach(select => {\n if (!metadata.hasColumnWithPropertyPath(`${select}`))\n throw new TypeORMError(`${select} column was not found in the ${metadata.name} entity.`);\n\n const columns = metadata.findColumnsWithPropertyPath(`${select}`);\n\n for (const column of columns) {\n qb.addSelect(qb.alias + \".\" + column.propertyPath);\n }\n });\n }\n\n if (options.relations) {\n // Copy because `applyRelationsRecursively` modifies it\n const allRelations = [...options.relations];\n this.applyRelationsRecursively(qb, allRelations, qb.expressionMap.mainAlias!.name, qb.expressionMap.mainAlias!.metadata, \"\");\n // recursive removes found relations from allRelations array\n // if there are relations left in this array it means those relations were not found in the entity structure\n // so, we give an exception about not found relations\n if (allRelations.length > 0)\n throw new FindRelationsNotFoundError(allRelations);\n }\n\n if (options.join) {\n if (options.join.leftJoin)\n Object.keys(options.join.leftJoin).forEach(key => {\n qb.leftJoin(options.join!.leftJoin![key], key);\n });\n\n if (options.join.innerJoin)\n Object.keys(options.join.innerJoin).forEach(key => {\n qb.innerJoin(options.join!.innerJoin![key], key);\n });\n\n if (options.join.leftJoinAndSelect)\n Object.keys(options.join.leftJoinAndSelect).forEach(key => {\n qb.leftJoinAndSelect(options.join!.leftJoinAndSelect![key], key);\n });\n\n if (options.join.innerJoinAndSelect)\n Object.keys(options.join.innerJoinAndSelect).forEach(key => {\n qb.innerJoinAndSelect(options.join!.innerJoinAndSelect![key], key);\n });\n }\n\n if (options.cache) {\n if (options.cache instanceof Object) {\n const cache = options.cache as { id: any, milliseconds: number };\n qb.cache(cache.id, cache.milliseconds);\n } else {\n qb.cache(options.cache);\n }\n }\n\n if (options.lock) {\n if (options.lock.mode === \"optimistic\") {\n qb.setLock(options.lock.mode, options.lock.version);\n } else if (\n options.lock.mode === \"pessimistic_read\" ||\n options.lock.mode === \"pessimistic_write\" ||\n options.lock.mode === \"dirty_read\" ||\n options.lock.mode === \"pessimistic_partial_write\" ||\n options.lock.mode === \"pessimistic_write_or_fail\" ||\n options.lock.mode === \"for_no_key_update\"\n ) {\n const tableNames = options.lock.tables ? options.lock.tables.map((table) => {\n const tableAlias = qb.expressionMap.aliases.find((alias) => {\n return alias.metadata.tableNameWithoutPrefix === table;\n });\n if (!tableAlias) {\n throw new TypeORMError(`\"${table}\" is not part of this query`);\n }\n return qb.escape(tableAlias.name);\n }) : undefined;\n qb.setLock(options.lock.mode, undefined, tableNames);\n }\n }\n\n if (options.loadRelationIds === true) {\n qb.loadAllRelationIds();\n\n } else if (options.loadRelationIds instanceof Object) {\n qb.loadAllRelationIds(options.loadRelationIds as any);\n }\n\n if (options.where)\n qb.where(options.where);\n\n if ((options as FindManyOptions<T>).skip)\n qb.skip((options as FindManyOptions<T>).skip!);\n\n if ((options as FindManyOptions<T>).take)\n qb.take((options as FindManyOptions<T>).take!);\n\n if (options.order)\n Object.keys(options.order).forEach(key => {\n const order = ((options as FindOneOptions<T>).order as any)[key as any];\n\n if (!metadata.findColumnWithPropertyPath(key))\n throw new Error(`${key} column was not found in the ${metadata.name} entity.`);\n\n switch (order) {\n case 1:\n qb.addOrderBy(qb.alias + \".\" + key, \"ASC\");\n break;\n case -1:\n qb.addOrderBy(qb.alias + \".\" + key, \"DESC\");\n break;\n case \"ASC\":\n qb.addOrderBy(qb.alias + \".\" + key, \"ASC\");\n break;\n case \"DESC\":\n qb.addOrderBy(qb.alias + \".\" + key, \"DESC\");\n break;\n }\n });\n\n return qb;\n }*/\n\n static applyOptionsToTreeQueryBuilder<T>(\n qb: SelectQueryBuilder<T>,\n options?: FindTreeOptions,\n ): SelectQueryBuilder<T> {\n if (options?.relations) {\n // Copy because `applyRelationsRecursively` modifies it\n const allRelations = [...options.relations]\n\n FindOptionsUtils.applyRelationsRecursively(\n qb,\n allRelations,\n qb.expressionMap.mainAlias!.name,\n qb.expressionMap.mainAlias!.metadata,\n \"\",\n )\n\n // recursive removes found relations from allRelations array\n // if there are relations left in this array it means those relations were not found in the entity structure\n // so, we give an exception about not found relations\n if (allRelations.length > 0)\n throw new FindRelationsNotFoundError(allRelations)\n }\n\n return qb\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Adds joins for all relations and sub-relations of the given relations provided in the find options.\n */\n public static applyRelationsRecursively(\n qb: SelectQueryBuilder<any>,\n allRelations: string[],\n alias: string,\n metadata: EntityMetadata,\n prefix: string,\n ): void {\n // find all relations that match given prefix\n let matchedBaseRelations: string[] = []\n if (prefix) {\n const regexp = new RegExp(\"^\" + prefix.replace(\".\", \"\\\\.\") + \"\\\\.\")\n matchedBaseRelations = allRelations\n .filter((relation) => relation.match(regexp))\n .map((relation) => relation.replace(regexp, \"\"))\n .filter((relation) =>\n metadata.findRelationWithPropertyPath(relation),\n )\n } else {\n matchedBaseRelations = allRelations.filter((relation) =>\n metadata.findRelationWithPropertyPath(relation),\n )\n }\n\n // go through all matched relations and add join for them\n matchedBaseRelations.forEach((relation) => {\n // generate a relation alias\n let relationAlias: string = DriverUtils.buildAlias(\n qb.connection.driver,\n { joiner: \"__\" },\n alias,\n relation,\n )\n\n // add a join for the found relation\n const selection = alias + \".\" + relation\n qb.leftJoinAndSelect(selection, relationAlias)\n\n // remove added relations from the allRelations array, this is needed to find all not found relations at the end\n allRelations.splice(\n allRelations.indexOf(\n prefix ? prefix + \".\" + relation : relation,\n ),\n 1,\n )\n\n // try to find sub-relations\n const join = qb.expressionMap.joinAttributes.find(\n (join) => join.entityOrProperty === selection,\n )\n this.applyRelationsRecursively(\n qb,\n allRelations,\n join!.alias.name,\n join!.metadata!,\n prefix ? prefix + \".\" + relation : relation,\n )\n\n // join the eager relations of the found relation\n const relMetadata = metadata.relations.find(\n (metadata) => metadata.propertyName === relation,\n )\n if (relMetadata) {\n this.joinEagerRelations(\n qb,\n relationAlias,\n relMetadata.inverseEntityMetadata,\n )\n }\n })\n }\n\n public static joinEagerRelations(\n qb: SelectQueryBuilder<any>,\n alias: string,\n metadata: EntityMetadata,\n ) {\n metadata.eagerRelations.forEach((relation) => {\n // generate a relation alias\n let relationAlias = DriverUtils.buildAlias(\n qb.connection.driver,\n qb.connection.namingStrategy.eagerJoinRelationAlias(\n alias,\n relation.propertyPath,\n ),\n )\n\n // add a join for the relation\n // Checking whether the relation wasn't joined yet.\n let addJoin = true\n for (const join of qb.expressionMap.joinAttributes) {\n if (\n join.condition !== undefined ||\n join.mapToProperty !== undefined ||\n join.isMappingMany !== undefined ||\n join.direction !== \"LEFT\" ||\n join.entityOrProperty !==\n `${alias}.${relation.propertyPath}`\n ) {\n continue\n }\n addJoin = false\n relationAlias = join.alias.name\n break\n }\n\n if (addJoin) {\n qb.leftJoin(alias + \".\" + relation.propertyPath, relationAlias)\n }\n\n // Checking whether the relation wasn't selected yet.\n // This check shall be after the join check to detect relationAlias.\n let addSelect = true\n for (const select of qb.expressionMap.selects) {\n if (\n select.aliasName !== undefined ||\n select.virtual !== undefined ||\n select.selection !== relationAlias\n ) {\n continue\n }\n addSelect = false\n break\n }\n\n if (addSelect) {\n qb.addSelect(relationAlias)\n }\n\n // (recursive) join the eager relations\n this.joinEagerRelations(\n qb,\n relationAlias,\n relation.inverseEntityMetadata,\n )\n })\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/find-options/FindOptionsUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAA;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGnD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,gBAAgB,CACnB,GAAQ;QAER,MAAM,eAAe,GAA2B,GAAG,CAAA;QACnD,OAAO,CACH,eAAe;YACf,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC;gBAClC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC;gBACxC,OAAO,eAAe,CAAC,MAAM,KAAK,QAAQ;gBAC1C,OAAO,eAAe,CAAC,SAAS,KAAK,QAAQ;gBAC7C,OAAO,eAAe,CAAC,KAAK,KAAK,QAAQ;gBACzC,+CAA+C;gBAC/C,OAAO,eAAe,CAAC,IAAI,KAAK,QAAQ;gBACxC,OAAO,eAAe,CAAC,KAAK,KAAK,QAAQ;gBACzC,OAAO,eAAe,CAAC,KAAK,KAAK,QAAQ;gBACzC,OAAO,eAAe,CAAC,KAAK,KAAK,SAAS;gBAC1C,OAAO,eAAe,CAAC,KAAK,KAAK,QAAQ;gBACzC,OAAO,eAAe,CAAC,OAAO,KAAK,QAAQ;gBAC3C,OAAO,eAAe,CAAC,IAAI,KAAK,QAAQ;gBACxC,OAAO,eAAe,CAAC,eAAe,KAAK,QAAQ;gBACnD,OAAO,eAAe,CAAC,eAAe,KAAK,SAAS;gBACpD,OAAO,eAAe,CAAC,kBAAkB,KAAK,S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;YAED,uCAAuC;YACvC,IAAI,CAAC,kBAAkB,CACnB,EAAE,EACF,aAAa,EACb,QAAQ,CAAC,qBAAqB,CACjC,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","file":"FindOptionsUtils.js","sourcesContent":["import { FindManyOptions } from \"./FindManyOptions\"\nimport { FindOneOptions } from \"./FindOneOptions\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { FindRelationsNotFoundError } from \"../error/FindRelationsNotFoundError\"\nimport { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport { DriverUtils } from \"../driver/DriverUtils\"\nimport { FindTreeOptions } from \"./FindTreeOptions\"\n\n/**\n * Utilities to work with FindOptions.\n */\nexport class FindOptionsUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if given object is really instance of FindOneOptions interface.\n */\n static isFindOneOptions<Entity = any>(\n obj: any,\n ): obj is FindOneOptions<Entity> {\n const possibleOptions: FindOneOptions<Entity> = obj\n return (\n possibleOptions &&\n (Array.isArray(possibleOptions.select) ||\n Array.isArray(possibleOptions.relations) ||\n typeof possibleOptions.select === \"object\" ||\n typeof possibleOptions.relations === \"object\" ||\n typeof possibleOptions.where === \"object\" ||\n // typeof possibleOptions.where === \"string\" ||\n typeof possibleOptions.join === \"object\" ||\n typeof possibleOptions.order === \"object\" ||\n typeof possibleOptions.cache === \"object\" ||\n typeof possibleOptions.cache === \"boolean\" ||\n typeof possibleOptions.cache === \"number\" ||\n typeof possibleOptions.comment === \"string\" ||\n typeof possibleOptions.lock === \"object\" ||\n typeof possibleOptions.loadRelationIds === \"object\" ||\n typeof possibleOptions.loadRelationIds === \"boolean\" ||\n typeof possibleOptions.loadEagerRelations === \"boolean\" ||\n typeof possibleOptions.withDeleted === \"boolean\" ||\n typeof possibleOptions.relationLoadStrategy === \"string\" ||\n typeof possibleOptions.transaction === \"boolean\")\n )\n }\n\n /**\n * Checks if given object is really instance of FindManyOptions interface.\n */\n static isFindManyOptions<Entity = any>(\n obj: any,\n ): obj is FindManyOptions<Entity> {\n const possibleOptions: FindManyOptions<Entity> = obj\n return (\n possibleOptions &&\n (this.isFindOneOptions(possibleOptions) ||\n typeof (possibleOptions as FindManyOptions<any>).skip ===\n \"number\" ||\n typeof (possibleOptions as FindManyOptions<any>).take ===\n \"number\" ||\n typeof (possibleOptions as FindManyOptions<any>).skip ===\n \"string\" ||\n typeof (possibleOptions as FindManyOptions<any>).take ===\n \"string\")\n )\n }\n\n /**\n * Checks if given object is really instance of FindOptions interface.\n */\n static extractFindManyOptionsAlias(object: any): string | undefined {\n if (this.isFindManyOptions(object) && object.join)\n return object.join.alias\n\n return undefined\n }\n\n /**\n * Applies give find many options to the given query builder.\n\n static applyFindManyOptionsOrConditionsToQueryBuilder<T>(qb: SelectQueryBuilder<T>, options: FindManyOptions<T>|Partial<T>|undefined): SelectQueryBuilder<T> {\n if (this.isFindManyOptions(options))\n return this.applyOptionsToQueryBuilder(qb, options);\n\n if (options)\n return qb.where(options);\n\n return qb;\n }*/\n\n /**\n * Applies give find options to the given query builder.\n\n static applyOptionsToQueryBuilder<T>(qb: SelectQueryBuilder<T>, options: FindOneOptions<T>|FindManyOptions<T>|undefined): SelectQueryBuilder<T> {\n\n // if options are not set then simply return query builder. This is made for simplicity of usage.\n if (!options || (!this.isFindOneOptions(options) && !this.isFindManyOptions(options)))\n return qb;\n\n if (options.transaction === true) {\n qb.expressionMap.useTransaction = true;\n }\n\n if (!qb.expressionMap.mainAlias || !qb.expressionMap.mainAlias.hasMetadata)\n return qb;\n\n const metadata = qb.expressionMap.mainAlias!.metadata;\n\n // apply all options from FindOptions\n if (options.comment) {\n qb.comment(options.comment);\n }\n\n if (options.withDeleted) {\n qb.withDeleted();\n }\n\n if (options.select) {\n qb.select([]);\n options.select.forEach(select => {\n if (!metadata.hasColumnWithPropertyPath(`${select}`))\n throw new TypeORMError(`${select} column was not found in the ${metadata.name} entity.`);\n\n const columns = metadata.findColumnsWithPropertyPath(`${select}`);\n\n for (const column of columns) {\n qb.addSelect(qb.alias + \".\" + column.propertyPath);\n }\n });\n }\n\n if (options.relations) {\n // Copy because `applyRelationsRecursively` modifies it\n const allRelations = [...options.relations];\n this.applyRelationsRecursively(qb, allRelations, qb.expressionMap.mainAlias!.name, qb.expressionMap.mainAlias!.metadata, \"\");\n // recursive removes found relations from allRelations array\n // if there are relations left in this array it means those relations were not found in the entity structure\n // so, we give an exception about not found relations\n if (allRelations.length > 0)\n throw new FindRelationsNotFoundError(allRelations);\n }\n\n if (options.join) {\n if (options.join.leftJoin)\n Object.keys(options.join.leftJoin).forEach(key => {\n qb.leftJoin(options.join!.leftJoin![key], key);\n });\n\n if (options.join.innerJoin)\n Object.keys(options.join.innerJoin).forEach(key => {\n qb.innerJoin(options.join!.innerJoin![key], key);\n });\n\n if (options.join.leftJoinAndSelect)\n Object.keys(options.join.leftJoinAndSelect).forEach(key => {\n qb.leftJoinAndSelect(options.join!.leftJoinAndSelect![key], key);\n });\n\n if (options.join.innerJoinAndSelect)\n Object.keys(options.join.innerJoinAndSelect).forEach(key => {\n qb.innerJoinAndSelect(options.join!.innerJoinAndSelect![key], key);\n });\n }\n\n if (options.cache) {\n if (options.cache instanceof Object) {\n const cache = options.cache as { id: any, milliseconds: number };\n qb.cache(cache.id, cache.milliseconds);\n } else {\n qb.cache(options.cache);\n }\n }\n\n if (options.lock) {\n if (options.lock.mode === \"optimistic\") {\n qb.setLock(options.lock.mode, options.lock.version);\n } else if (\n options.lock.mode === \"pessimistic_read\" ||\n options.lock.mode === \"pessimistic_write\" ||\n options.lock.mode === \"dirty_read\" ||\n options.lock.mode === \"pessimistic_partial_write\" ||\n options.lock.mode === \"pessimistic_write_or_fail\" ||\n options.lock.mode === \"for_no_key_update\" ||\n options.lock.mode === \"for_key_share\"\n ) {\n const tableNames = options.lock.tables ? options.lock.tables.map((table) => {\n const tableAlias = qb.expressionMap.aliases.find((alias) => {\n return alias.metadata.tableNameWithoutPrefix === table;\n });\n if (!tableAlias) {\n throw new TypeORMError(`\"${table}\" is not part of this query`);\n }\n return qb.escape(tableAlias.name);\n }) : undefined;\n qb.setLock(options.lock.mode, undefined, tableNames);\n }\n }\n\n if (options.loadRelationIds === true) {\n qb.loadAllRelationIds();\n\n } else if (options.loadRelationIds instanceof Object) {\n qb.loadAllRelationIds(options.loadRelationIds as any);\n }\n\n if (options.where)\n qb.where(options.where);\n\n if ((options as FindManyOptions<T>).skip)\n qb.skip((options as FindManyOptions<T>).skip!);\n\n if ((options as FindManyOptions<T>).take)\n qb.take((options as FindManyOptions<T>).take!);\n\n if (options.order)\n Object.keys(options.order).forEach(key => {\n const order = ((options as FindOneOptions<T>).order as any)[key as any];\n\n if (!metadata.findColumnWithPropertyPath(key))\n throw new Error(`${key} column was not found in the ${metadata.name} entity.`);\n\n switch (order) {\n case 1:\n qb.addOrderBy(qb.alias + \".\" + key, \"ASC\");\n break;\n case -1:\n qb.addOrderBy(qb.alias + \".\" + key, \"DESC\");\n break;\n case \"ASC\":\n qb.addOrderBy(qb.alias + \".\" + key, \"ASC\");\n break;\n case \"DESC\":\n qb.addOrderBy(qb.alias + \".\" + key, \"DESC\");\n break;\n }\n });\n\n return qb;\n }*/\n\n static applyOptionsToTreeQueryBuilder<T>(\n qb: SelectQueryBuilder<T>,\n options?: FindTreeOptions,\n ): SelectQueryBuilder<T> {\n if (options?.relations) {\n // Copy because `applyRelationsRecursively` modifies it\n const allRelations = [...options.relations]\n\n FindOptionsUtils.applyRelationsRecursively(\n qb,\n allRelations,\n qb.expressionMap.mainAlias!.name,\n qb.expressionMap.mainAlias!.metadata,\n \"\",\n )\n\n // recursive removes found relations from allRelations array\n // if there are relations left in this array it means those relations were not found in the entity structure\n // so, we give an exception about not found relations\n if (allRelations.length > 0)\n throw new FindRelationsNotFoundError(allRelations)\n }\n\n return qb\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Adds joins for all relations and sub-relations of the given relations provided in the find options.\n */\n public static applyRelationsRecursively(\n qb: SelectQueryBuilder<any>,\n allRelations: string[],\n alias: string,\n metadata: EntityMetadata,\n prefix: string,\n ): void {\n // find all relations that match given prefix\n let matchedBaseRelations: string[] = []\n if (prefix) {\n const regexp = new RegExp(\"^\" + prefix.replace(\".\", \"\\\\.\") + \"\\\\.\")\n matchedBaseRelations = allRelations\n .filter((relation) => relation.match(regexp))\n .map((relation) => relation.replace(regexp, \"\"))\n .filter((relation) =>\n metadata.findRelationWithPropertyPath(relation),\n )\n } else {\n matchedBaseRelations = allRelations.filter((relation) =>\n metadata.findRelationWithPropertyPath(relation),\n )\n }\n\n // go through all matched relations and add join for them\n matchedBaseRelations.forEach((relation) => {\n // generate a relation alias\n let relationAlias: string = DriverUtils.buildAlias(\n qb.connection.driver,\n { joiner: \"__\" },\n alias,\n relation,\n )\n\n // add a join for the found relation\n const selection = alias + \".\" + relation\n qb.leftJoinAndSelect(selection, relationAlias)\n\n // remove added relations from the allRelations array, this is needed to find all not found relations at the end\n allRelations.splice(\n allRelations.indexOf(\n prefix ? prefix + \".\" + relation : relation,\n ),\n 1,\n )\n\n // try to find sub-relations\n const join = qb.expressionMap.joinAttributes.find(\n (join) => join.entityOrProperty === selection,\n )\n this.applyRelationsRecursively(\n qb,\n allRelations,\n join!.alias.name,\n join!.metadata!,\n prefix ? prefix + \".\" + relation : relation,\n )\n\n // join the eager relations of the found relation\n const relMetadata = metadata.relations.find(\n (metadata) => metadata.propertyName === relation,\n )\n if (relMetadata) {\n this.joinEagerRelations(\n qb,\n relationAlias,\n relMetadata.inverseEntityMetadata,\n )\n }\n })\n }\n\n public static joinEagerRelations(\n qb: SelectQueryBuilder<any>,\n alias: string,\n metadata: EntityMetadata,\n ) {\n metadata.eagerRelations.forEach((relation) => {\n // generate a relation alias\n let relationAlias = DriverUtils.buildAlias(\n qb.connection.driver,\n qb.connection.namingStrategy.eagerJoinRelationAlias(\n alias,\n relation.propertyPath,\n ),\n )\n\n // add a join for the relation\n // Checking whether the relation wasn't joined yet.\n let addJoin = true\n for (const join of qb.expressionMap.joinAttributes) {\n if (\n join.condition !== undefined ||\n join.mapToProperty !== undefined ||\n join.isMappingMany !== undefined ||\n join.direction !== \"LEFT\" ||\n join.entityOrProperty !==\n `${alias}.${relation.propertyPath}`\n ) {\n continue\n }\n addJoin = false\n relationAlias = join.alias.name\n break\n }\n\n if (addJoin) {\n qb.leftJoin(alias + \".\" + relation.propertyPath, relationAlias)\n }\n\n // Checking whether the relation wasn't selected yet.\n // This check shall be after the join check to detect relationAlias.\n let addSelect = true\n for (const select of qb.expressionMap.selects) {\n if (\n select.aliasName !== undefined ||\n select.virtual !== undefined ||\n select.selection !== relationAlias\n ) {\n continue\n }\n addSelect = false\n break\n }\n\n if (addSelect) {\n qb.addSelect(relationAlias)\n }\n\n // (recursive) join the eager relations\n this.joinEagerRelations(\n qb,\n relationAlias,\n relation.inverseEntityMetadata,\n )\n })\n }\n}\n"],"sourceRoot":".."}
|
package/browser/index.d.ts
CHANGED
|
@@ -61,6 +61,9 @@ export * from "./decorator/Exclusion";
|
|
|
61
61
|
export * from "./decorator/Generated";
|
|
62
62
|
export * from "./decorator/EntityRepository";
|
|
63
63
|
export * from "./find-options/operator/Any";
|
|
64
|
+
export * from "./find-options/operator/ArrayContainedBy";
|
|
65
|
+
export * from "./find-options/operator/ArrayContains";
|
|
66
|
+
export * from "./find-options/operator/ArrayOverlap";
|
|
64
67
|
export * from "./find-options/operator/Between";
|
|
65
68
|
export * from "./find-options/operator/Equal";
|
|
66
69
|
export * from "./find-options/operator/In";
|
|
@@ -120,6 +123,7 @@ export * from "./driver/types/DatabaseType";
|
|
|
120
123
|
export * from "./driver/types/ReplicationMode";
|
|
121
124
|
export * from "./driver/sqlserver/MssqlParameter";
|
|
122
125
|
export { ConnectionOptionsReader } from "./connection/ConnectionOptionsReader";
|
|
126
|
+
export { ConnectionOptions } from "./connection/ConnectionOptions";
|
|
123
127
|
export { DataSource } from "./data-source/DataSource";
|
|
124
128
|
export { Connection } from "./connection/Connection";
|
|
125
129
|
export { ConnectionManager } from "./connection/ConnectionManager";
|
package/browser/index.js
CHANGED
|
@@ -64,6 +64,9 @@ export * from "./decorator/Exclusion";
|
|
|
64
64
|
export * from "./decorator/Generated";
|
|
65
65
|
export * from "./decorator/EntityRepository";
|
|
66
66
|
export * from "./find-options/operator/Any";
|
|
67
|
+
export * from "./find-options/operator/ArrayContainedBy";
|
|
68
|
+
export * from "./find-options/operator/ArrayContains";
|
|
69
|
+
export * from "./find-options/operator/ArrayOverlap";
|
|
67
70
|
export * from "./find-options/operator/Between";
|
|
68
71
|
export * from "./find-options/operator/Equal";
|
|
69
72
|
export * from "./find-options/operator/In";
|
package/browser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/index.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,kBAAkB,CAAA;AAEzB,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA;AACvB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sCAAsC,CAAA;AACpD,cAAc,sCAAsC,CAAA;AACpD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mCAAmC,CAAA;AACjD,cAAc,uCAAuC,CAAA;AACrD,cAAc,oCAAoC,C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O,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAA;AAErG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA","file":"index.js","sourcesContent":["/*!\n */\nimport \"reflect-metadata\"\n\n// -------------------------------------------------------------------------\n// Commonly Used exports\n// -------------------------------------------------------------------------\n\nexport * from \"./globals\"\nexport * from \"./container\"\nexport * from \"./common/EntityTarget\"\nexport * from \"./common/ObjectType\"\nexport * from \"./common/ObjectLiteral\"\nexport * from \"./common/MixedList\"\nexport * from \"./common/DeepPartial\"\nexport * from \"./common/RelationType\"\nexport * from \"./error\"\nexport * from \"./decorator/columns/Column\"\nexport * from \"./decorator/columns/CreateDateColumn\"\nexport * from \"./decorator/columns/DeleteDateColumn\"\nexport * from \"./decorator/columns/PrimaryGeneratedColumn\"\nexport * from \"./decorator/columns/PrimaryColumn\"\nexport * from \"./decorator/columns/UpdateDateColumn\"\nexport * from \"./decorator/columns/VersionColumn\"\nexport * from \"./decorator/columns/ViewColumn\"\nexport * from \"./decorator/columns/ObjectIdColumn\"\nexport * from \"./decorator/listeners/AfterInsert\"\nexport * from \"./decorator/listeners/AfterLoad\"\nexport * from \"./decorator/listeners/AfterRemove\"\nexport * from \"./decorator/listeners/AfterSoftRemove\"\nexport * from \"./decorator/listeners/AfterRecover\"\nexport * from \"./decorator/listeners/AfterUpdate\"\nexport * from \"./decorator/listeners/BeforeInsert\"\nexport * from \"./decorator/listeners/BeforeRemove\"\nexport * from \"./decorator/listeners/BeforeSoftRemove\"\nexport * from \"./decorator/listeners/BeforeRecover\"\nexport * from \"./decorator/listeners/BeforeUpdate\"\nexport * from \"./decorator/listeners/EventSubscriber\"\nexport * from \"./decorator/options/ColumnOptions\"\nexport * from \"./decorator/options/IndexOptions\"\nexport * from \"./decorator/options/JoinColumnOptions\"\nexport * from \"./decorator/options/JoinTableOptions\"\nexport * from \"./decorator/options/RelationOptions\"\nexport * from \"./decorator/options/EntityOptions\"\nexport * from \"./decorator/options/ValueTransformer\"\nexport * from \"./decorator/relations/JoinColumn\"\nexport * from \"./decorator/relations/JoinTable\"\nexport * from \"./decorator/relations/ManyToMany\"\nexport * from \"./decorator/relations/ManyToOne\"\nexport * from \"./decorator/relations/OneToMany\"\nexport * from \"./decorator/relations/OneToOne\"\nexport * from \"./decorator/relations/RelationCount\"\nexport * from \"./decorator/relations/RelationId\"\nexport * from \"./decorator/entity/Entity\"\nexport * from \"./decorator/entity/ChildEntity\"\nexport * from \"./decorator/entity/TableInheritance\"\nexport * from \"./decorator/entity-view/ViewEntity\"\nexport * from \"./decorator/tree/TreeLevelColumn\"\nexport * from \"./decorator/tree/TreeParent\"\nexport * from \"./decorator/tree/TreeChildren\"\nexport * from \"./decorator/tree/Tree\"\nexport * from \"./decorator/Index\"\nexport * from \"./decorator/Unique\"\nexport * from \"./decorator/Check\"\nexport * from \"./decorator/Exclusion\"\nexport * from \"./decorator/Generated\"\nexport * from \"./decorator/EntityRepository\"\nexport * from \"./find-options/operator/Any\"\nexport * from \"./find-options/operator/Between\"\nexport * from \"./find-options/operator/Equal\"\nexport * from \"./find-options/operator/In\"\nexport * from \"./find-options/operator/IsNull\"\nexport * from \"./find-options/operator/LessThan\"\nexport * from \"./find-options/operator/LessThanOrEqual\"\nexport * from \"./find-options/operator/ILike\"\nexport * from \"./find-options/operator/Like\"\nexport * from \"./find-options/operator/MoreThan\"\nexport * from \"./find-options/operator/MoreThanOrEqual\"\nexport * from \"./find-options/operator/Not\"\nexport * from \"./find-options/operator/Raw\"\nexport * from \"./find-options/EqualOperator\"\nexport * from \"./find-options/FindManyOptions\"\nexport * from \"./find-options/FindOneOptions\"\nexport * from \"./find-options/FindOperator\"\nexport * from \"./find-options/FindOperatorType\"\nexport * from \"./find-options/FindOptionsOrder\"\nexport * from \"./find-options/FindOptionsRelations\"\nexport * from \"./find-options/FindOptionsSelect\"\nexport * from \"./find-options/FindOptionsUtils\"\nexport * from \"./find-options/FindOptionsWhere\"\nexport * from \"./find-options/FindTreeOptions\"\nexport * from \"./find-options/JoinOptions\"\nexport * from \"./find-options/OrderByCondition\"\nexport * from \"./logger/Logger\"\nexport * from \"./logger/LoggerOptions\"\nexport * from \"./logger/AdvancedConsoleLogger\"\nexport * from \"./logger/SimpleConsoleLogger\"\nexport * from \"./logger/FileLogger\"\nexport * from \"./metadata/EntityMetadata\"\nexport * from \"./entity-manager/EntityManager\"\nexport * from \"./repository/AbstractRepository\"\nexport * from \"./repository/Repository\"\nexport * from \"./repository/BaseEntity\"\nexport * from \"./repository/TreeRepository\"\nexport * from \"./repository/MongoRepository\"\nexport * from \"./repository/RemoveOptions\"\nexport * from \"./repository/SaveOptions\"\nexport * from \"./schema-builder/table/TableCheck\"\nexport * from \"./schema-builder/table/TableColumn\"\nexport * from \"./schema-builder/table/TableExclusion\"\nexport * from \"./schema-builder/table/TableForeignKey\"\nexport * from \"./schema-builder/table/TableIndex\"\nexport * from \"./schema-builder/table/TableUnique\"\nexport * from \"./schema-builder/table/Table\"\nexport * from \"./schema-builder/options/TableCheckOptions\"\nexport * from \"./schema-builder/options/TableColumnOptions\"\nexport * from \"./schema-builder/options/TableExclusionOptions\"\nexport * from \"./schema-builder/options/TableForeignKeyOptions\"\nexport * from \"./schema-builder/options/TableIndexOptions\"\nexport * from \"./schema-builder/options/TableOptions\"\nexport * from \"./schema-builder/options/TableUniqueOptions\"\nexport * from \"./schema-builder/options/ViewOptions\"\nexport * from \"./driver/mongodb/typings\"\nexport * from \"./driver/types/DatabaseType\"\nexport * from \"./driver/types/ReplicationMode\"\nexport * from \"./driver/sqlserver/MssqlParameter\"\n\n// export * from \"./data-source\";\n\nexport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nexport { DataSource } from \"./data-source/DataSource\"\nexport { Connection } from \"./connection/Connection\"\nexport { ConnectionManager } from \"./connection/ConnectionManager\"\nexport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nexport { Driver } from \"./driver/Driver\"\nexport { QueryBuilder } from \"./query-builder/QueryBuilder\"\nexport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nexport { DeleteQueryBuilder } from \"./query-builder/DeleteQueryBuilder\"\nexport { InsertQueryBuilder } from \"./query-builder/InsertQueryBuilder\"\nexport { UpdateQueryBuilder } from \"./query-builder/UpdateQueryBuilder\"\nexport { RelationQueryBuilder } from \"./query-builder/RelationQueryBuilder\"\nexport { Brackets } from \"./query-builder/Brackets\"\nexport { NotBrackets } from \"./query-builder/NotBrackets\"\nexport { WhereExpressionBuilder } from \"./query-builder/WhereExpressionBuilder\"\nexport { WhereExpression } from \"./query-builder/WhereExpressionBuilder\"\nexport { InsertResult } from \"./query-builder/result/InsertResult\"\nexport { UpdateResult } from \"./query-builder/result/UpdateResult\"\nexport { DeleteResult } from \"./query-builder/result/DeleteResult\"\nexport { QueryResult } from \"./query-runner/QueryResult\"\nexport { QueryRunner } from \"./query-runner/QueryRunner\"\nexport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nexport { Migration } from \"./migration/Migration\"\nexport { MigrationExecutor } from \"./migration/MigrationExecutor\"\nexport { MigrationInterface } from \"./migration/MigrationInterface\"\nexport { DefaultNamingStrategy } from \"./naming-strategy/DefaultNamingStrategy\"\nexport { NamingStrategyInterface } from \"./naming-strategy/NamingStrategyInterface\"\nexport { InsertEvent } from \"./subscriber/event/InsertEvent\"\nexport { LoadEvent } from \"./subscriber/event/LoadEvent\"\nexport { UpdateEvent } from \"./subscriber/event/UpdateEvent\"\nexport { RemoveEvent } from \"./subscriber/event/RemoveEvent\"\nexport { TransactionCommitEvent } from \"./subscriber/event/TransactionCommitEvent\"\nexport { TransactionRollbackEvent } from \"./subscriber/event/TransactionRollbackEvent\"\nexport { TransactionStartEvent } from \"./subscriber/event/TransactionStartEvent\"\nexport { EntitySubscriberInterface } from \"./subscriber/EntitySubscriberInterface\"\nexport { EntitySchema } from \"./entity-schema/EntitySchema\"\nexport { EntitySchemaColumnOptions } from \"./entity-schema/EntitySchemaColumnOptions\"\nexport { EntitySchemaIndexOptions } from \"./entity-schema/EntitySchemaIndexOptions\"\nexport { EntitySchemaRelationOptions } from \"./entity-schema/EntitySchemaRelationOptions\"\nexport { EntitySchemaEmbeddedColumnOptions } from \"./entity-schema/EntitySchemaEmbeddedColumnOptions\"\nexport { ColumnType } from \"./driver/types/ColumnTypes\"\nexport { EntitySchemaOptions } from \"./entity-schema/EntitySchemaOptions\"\nexport { InstanceChecker } from \"./util/InstanceChecker\"\nexport { TreeRepositoryUtils } from \"./util/TreeRepositoryUtils\"\n"],"sourceRoot":"."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/index.ts"],"names":[],"mappings":"AAAA;GACG;AACH,OAAO,kBAAkB,CAAA;AAEzB,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,SAAS,CAAA;AACvB,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sCAAsC,CAAA;AACpD,cAAc,sCAAsC,CAAA;AACpD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mCAAmC,CAAA;AACjD,cAAc,uCAAuC,CAAA;AACrD,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,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M,8BAA8B,CAAA;AAI3D,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAA;AAErG,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA","file":"index.js","sourcesContent":["/*!\n */\nimport \"reflect-metadata\"\n\n// -------------------------------------------------------------------------\n// Commonly Used exports\n// -------------------------------------------------------------------------\n\nexport * from \"./globals\"\nexport * from \"./container\"\nexport * from \"./common/EntityTarget\"\nexport * from \"./common/ObjectType\"\nexport * from \"./common/ObjectLiteral\"\nexport * from \"./common/MixedList\"\nexport * from \"./common/DeepPartial\"\nexport * from \"./common/RelationType\"\nexport * from \"./error\"\nexport * from \"./decorator/columns/Column\"\nexport * from \"./decorator/columns/CreateDateColumn\"\nexport * from \"./decorator/columns/DeleteDateColumn\"\nexport * from \"./decorator/columns/PrimaryGeneratedColumn\"\nexport * from \"./decorator/columns/PrimaryColumn\"\nexport * from \"./decorator/columns/UpdateDateColumn\"\nexport * from \"./decorator/columns/VersionColumn\"\nexport * from \"./decorator/columns/ViewColumn\"\nexport * from \"./decorator/columns/ObjectIdColumn\"\nexport * from \"./decorator/listeners/AfterInsert\"\nexport * from \"./decorator/listeners/AfterLoad\"\nexport * from \"./decorator/listeners/AfterRemove\"\nexport * from \"./decorator/listeners/AfterSoftRemove\"\nexport * from \"./decorator/listeners/AfterRecover\"\nexport * from \"./decorator/listeners/AfterUpdate\"\nexport * from \"./decorator/listeners/BeforeInsert\"\nexport * from \"./decorator/listeners/BeforeRemove\"\nexport * from \"./decorator/listeners/BeforeSoftRemove\"\nexport * from \"./decorator/listeners/BeforeRecover\"\nexport * from \"./decorator/listeners/BeforeUpdate\"\nexport * from \"./decorator/listeners/EventSubscriber\"\nexport * from \"./decorator/options/ColumnOptions\"\nexport * from \"./decorator/options/IndexOptions\"\nexport * from \"./decorator/options/JoinColumnOptions\"\nexport * from \"./decorator/options/JoinTableOptions\"\nexport * from \"./decorator/options/RelationOptions\"\nexport * from \"./decorator/options/EntityOptions\"\nexport * from \"./decorator/options/ValueTransformer\"\nexport * from \"./decorator/relations/JoinColumn\"\nexport * from \"./decorator/relations/JoinTable\"\nexport * from \"./decorator/relations/ManyToMany\"\nexport * from \"./decorator/relations/ManyToOne\"\nexport * from \"./decorator/relations/OneToMany\"\nexport * from \"./decorator/relations/OneToOne\"\nexport * from \"./decorator/relations/RelationCount\"\nexport * from \"./decorator/relations/RelationId\"\nexport * from \"./decorator/entity/Entity\"\nexport * from \"./decorator/entity/ChildEntity\"\nexport * from \"./decorator/entity/TableInheritance\"\nexport * from \"./decorator/entity-view/ViewEntity\"\nexport * from \"./decorator/tree/TreeLevelColumn\"\nexport * from \"./decorator/tree/TreeParent\"\nexport * from \"./decorator/tree/TreeChildren\"\nexport * from \"./decorator/tree/Tree\"\nexport * from \"./decorator/Index\"\nexport * from \"./decorator/Unique\"\nexport * from \"./decorator/Check\"\nexport * from \"./decorator/Exclusion\"\nexport * from \"./decorator/Generated\"\nexport * from \"./decorator/EntityRepository\"\nexport * from \"./find-options/operator/Any\"\nexport * from \"./find-options/operator/ArrayContainedBy\"\nexport * from \"./find-options/operator/ArrayContains\"\nexport * from \"./find-options/operator/ArrayOverlap\"\nexport * from \"./find-options/operator/Between\"\nexport * from \"./find-options/operator/Equal\"\nexport * from \"./find-options/operator/In\"\nexport * from \"./find-options/operator/IsNull\"\nexport * from \"./find-options/operator/LessThan\"\nexport * from \"./find-options/operator/LessThanOrEqual\"\nexport * from \"./find-options/operator/ILike\"\nexport * from \"./find-options/operator/Like\"\nexport * from \"./find-options/operator/MoreThan\"\nexport * from \"./find-options/operator/MoreThanOrEqual\"\nexport * from \"./find-options/operator/Not\"\nexport * from \"./find-options/operator/Raw\"\nexport * from \"./find-options/EqualOperator\"\nexport * from \"./find-options/FindManyOptions\"\nexport * from \"./find-options/FindOneOptions\"\nexport * from \"./find-options/FindOperator\"\nexport * from \"./find-options/FindOperatorType\"\nexport * from \"./find-options/FindOptionsOrder\"\nexport * from \"./find-options/FindOptionsRelations\"\nexport * from \"./find-options/FindOptionsSelect\"\nexport * from \"./find-options/FindOptionsUtils\"\nexport * from \"./find-options/FindOptionsWhere\"\nexport * from \"./find-options/FindTreeOptions\"\nexport * from \"./find-options/JoinOptions\"\nexport * from \"./find-options/OrderByCondition\"\nexport * from \"./logger/Logger\"\nexport * from \"./logger/LoggerOptions\"\nexport * from \"./logger/AdvancedConsoleLogger\"\nexport * from \"./logger/SimpleConsoleLogger\"\nexport * from \"./logger/FileLogger\"\nexport * from \"./metadata/EntityMetadata\"\nexport * from \"./entity-manager/EntityManager\"\nexport * from \"./repository/AbstractRepository\"\nexport * from \"./repository/Repository\"\nexport * from \"./repository/BaseEntity\"\nexport * from \"./repository/TreeRepository\"\nexport * from \"./repository/MongoRepository\"\nexport * from \"./repository/RemoveOptions\"\nexport * from \"./repository/SaveOptions\"\nexport * from \"./schema-builder/table/TableCheck\"\nexport * from \"./schema-builder/table/TableColumn\"\nexport * from \"./schema-builder/table/TableExclusion\"\nexport * from \"./schema-builder/table/TableForeignKey\"\nexport * from \"./schema-builder/table/TableIndex\"\nexport * from \"./schema-builder/table/TableUnique\"\nexport * from \"./schema-builder/table/Table\"\nexport * from \"./schema-builder/options/TableCheckOptions\"\nexport * from \"./schema-builder/options/TableColumnOptions\"\nexport * from \"./schema-builder/options/TableExclusionOptions\"\nexport * from \"./schema-builder/options/TableForeignKeyOptions\"\nexport * from \"./schema-builder/options/TableIndexOptions\"\nexport * from \"./schema-builder/options/TableOptions\"\nexport * from \"./schema-builder/options/TableUniqueOptions\"\nexport * from \"./schema-builder/options/ViewOptions\"\nexport * from \"./driver/mongodb/typings\"\nexport * from \"./driver/types/DatabaseType\"\nexport * from \"./driver/types/ReplicationMode\"\nexport * from \"./driver/sqlserver/MssqlParameter\"\n\n// export * from \"./data-source\";\n\nexport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nexport { ConnectionOptions } from \"./connection/ConnectionOptions\"\nexport { DataSource } from \"./data-source/DataSource\"\nexport { Connection } from \"./connection/Connection\"\nexport { ConnectionManager } from \"./connection/ConnectionManager\"\nexport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nexport { Driver } from \"./driver/Driver\"\nexport { QueryBuilder } from \"./query-builder/QueryBuilder\"\nexport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nexport { DeleteQueryBuilder } from \"./query-builder/DeleteQueryBuilder\"\nexport { InsertQueryBuilder } from \"./query-builder/InsertQueryBuilder\"\nexport { UpdateQueryBuilder } from \"./query-builder/UpdateQueryBuilder\"\nexport { RelationQueryBuilder } from \"./query-builder/RelationQueryBuilder\"\nexport { Brackets } from \"./query-builder/Brackets\"\nexport { NotBrackets } from \"./query-builder/NotBrackets\"\nexport { WhereExpressionBuilder } from \"./query-builder/WhereExpressionBuilder\"\nexport { WhereExpression } from \"./query-builder/WhereExpressionBuilder\"\nexport { InsertResult } from \"./query-builder/result/InsertResult\"\nexport { UpdateResult } from \"./query-builder/result/UpdateResult\"\nexport { DeleteResult } from \"./query-builder/result/DeleteResult\"\nexport { QueryResult } from \"./query-runner/QueryResult\"\nexport { QueryRunner } from \"./query-runner/QueryRunner\"\nexport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nexport { Migration } from \"./migration/Migration\"\nexport { MigrationExecutor } from \"./migration/MigrationExecutor\"\nexport { MigrationInterface } from \"./migration/MigrationInterface\"\nexport { DefaultNamingStrategy } from \"./naming-strategy/DefaultNamingStrategy\"\nexport { NamingStrategyInterface } from \"./naming-strategy/NamingStrategyInterface\"\nexport { InsertEvent } from \"./subscriber/event/InsertEvent\"\nexport { LoadEvent } from \"./subscriber/event/LoadEvent\"\nexport { UpdateEvent } from \"./subscriber/event/UpdateEvent\"\nexport { RemoveEvent } from \"./subscriber/event/RemoveEvent\"\nexport { TransactionCommitEvent } from \"./subscriber/event/TransactionCommitEvent\"\nexport { TransactionRollbackEvent } from \"./subscriber/event/TransactionRollbackEvent\"\nexport { TransactionStartEvent } from \"./subscriber/event/TransactionStartEvent\"\nexport { EntitySubscriberInterface } from \"./subscriber/EntitySubscriberInterface\"\nexport { EntitySchema } from \"./entity-schema/EntitySchema\"\nexport { EntitySchemaColumnOptions } from \"./entity-schema/EntitySchemaColumnOptions\"\nexport { EntitySchemaIndexOptions } from \"./entity-schema/EntitySchemaIndexOptions\"\nexport { EntitySchemaRelationOptions } from \"./entity-schema/EntitySchemaRelationOptions\"\nexport { EntitySchemaEmbeddedColumnOptions } from \"./entity-schema/EntitySchemaEmbeddedColumnOptions\"\nexport { ColumnType } from \"./driver/types/ColumnTypes\"\nexport { EntitySchemaOptions } from \"./entity-schema/EntitySchemaOptions\"\nexport { InstanceChecker } from \"./util/InstanceChecker\"\nexport { TreeRepositoryUtils } from \"./util/TreeRepositoryUtils\"\n"],"sourceRoot":"."}
|
|
@@ -62,8 +62,19 @@ export class EntityPersistExecutor {
|
|
|
62
62
|
: entity.constructor;
|
|
63
63
|
if (entityTarget === Object)
|
|
64
64
|
throw new CannotDetermineEntityError(this.mode);
|
|
65
|
+
let metadata = this.connection.getMetadata(entityTarget);
|
|
66
|
+
// Check for single table inheritance and find the correct metadata in that case.
|
|
67
|
+
// Goal is to use the correct discriminator as we could have a repository
|
|
68
|
+
// for an (abstract) base class and thus the target would not match.
|
|
69
|
+
if (metadata.inheritancePattern === "STI" &&
|
|
70
|
+
metadata.childEntityMetadatas.length > 0) {
|
|
71
|
+
const matchingChildMetadata = metadata.childEntityMetadatas.find((meta) => entity.constructor === meta.target);
|
|
72
|
+
if (matchingChildMetadata) {
|
|
73
|
+
metadata = matchingChildMetadata;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
65
76
|
subjects.push(new Subject({
|
|
66
|
-
metadata
|
|
77
|
+
metadata,
|
|
67
78
|
entity: entity,
|
|
68
79
|
canBeInserted: this.mode === "save",
|
|
69
80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AI,iCAAiC,EAAE;oBACtD,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAA;iBAC3B;gBACD,qDAAqD;gBAErD,6CAA6C;gBAC7C,0BAA0B;gBAC1B,IAAI,wBAAwB,KAAK,IAAI;oBACjC,MAAM,WAAW,CAAC,iBAAiB,EAAE,CAAA;gBACzC,6BAA6B;aAChC;YAAC,OAAO,KAAK,EAAE;gBACZ,+CAA+C;gBAC/C,IAAI,wBAAwB,EAAE;oBAC1B,IAAI;wBACA,MAAM,WAAW,CAAC,mBAAmB,EAAE,CAAA;qBAC1C;oBAAC,OAAO,aAAa,EAAE,GAAE;iBAC7B;gBACD,MAAM,KAAK,CAAA;aACd;SACJ;gBAAS;YACN,WAAW,CAAC,IAAI,GAAG,kBAAkB,CAAA;YAErC,iDAAiD;YACjD,IAAI,CAAC,IAAI,CAAC,WAAW;gBAAE,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;SACrD;IACL,CAAC;CACJ","file":"EntityPersistExecutor.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { MustBeEntityError } from \"../error/MustBeEntityError\"\nimport { SubjectExecutor } from \"./SubjectExecutor\"\nimport { CannotDetermineEntityError } from \"../error/CannotDetermineEntityError\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { Subject } from \"./Subject\"\nimport { OneToManySubjectBuilder } from \"./subject-builder/OneToManySubjectBuilder\"\nimport { OneToOneInverseSideSubjectBuilder } from \"./subject-builder/OneToOneInverseSideSubjectBuilder\"\nimport { ManyToManySubjectBuilder } from \"./subject-builder/ManyToManySubjectBuilder\"\nimport { SubjectDatabaseEntityLoader } from \"./SubjectDatabaseEntityLoader\"\nimport { CascadesSubjectBuilder } from \"./subject-builder/CascadesSubjectBuilder\"\nimport { OrmUtils } from \"../util/OrmUtils\"\n\n/**\n * Persists a single entity or multiple entities - saves or removes them.\n */\nexport class EntityPersistExecutor {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n protected queryRunner: QueryRunner | undefined,\n protected mode: \"save\" | \"remove\" | \"soft-remove\" | \"recover\",\n protected target: Function | string | undefined,\n protected entity: ObjectLiteral | ObjectLiteral[],\n protected options?: SaveOptions & RemoveOptions,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Executes persistence operation ob given entity or entities.\n */\n async execute(): Promise<void> {\n // check if entity we are going to save is valid and is an object\n if (!this.entity || typeof this.entity !== \"object\")\n return Promise.reject(new MustBeEntityError(this.mode, this.entity))\n\n // we MUST call \"fake\" resolve here to make sure all properties of lazily loaded relations are resolved\n await Promise.resolve()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n // save data in the query runner - this is useful functionality to share data from outside of the world\n // with third classes - like subscribers and listener methods\n let oldQueryRunnerData = queryRunner.data\n if (this.options && this.options.data) {\n queryRunner.data = this.options.data\n }\n\n try {\n // collect all operate subjects\n const entities: ObjectLiteral[] = Array.isArray(this.entity)\n ? this.entity\n : [this.entity]\n const entitiesInChunks =\n this.options && this.options.chunk && this.options.chunk > 0\n ? OrmUtils.chunk(entities, this.options.chunk)\n : [entities]\n\n // console.time(\"building subject executors...\");\n const executors = await Promise.all(\n entitiesInChunks.map(async (entities) => {\n const subjects: Subject[] = []\n\n // create subjects for all entities we received for the persistence\n entities.forEach((entity) => {\n const entityTarget = this.target\n ? this.target\n : entity.constructor\n if (entityTarget === Object)\n throw new CannotDetermineEntityError(this.mode)\n\n subjects.push(\n new Subject({\n metadata:\n this.connection.getMetadata(entityTarget),\n entity: entity,\n canBeInserted: this.mode === \"save\",\n canBeUpdated: this.mode === \"save\",\n mustBeRemoved: this.mode === \"remove\",\n canBeSoftRemoved: this.mode === \"soft-remove\",\n canBeRecovered: this.mode === \"recover\",\n }),\n )\n })\n\n // console.time(\"building cascades...\");\n // go through each entity with metadata and create subjects and subjects by cascades for them\n const cascadesSubjectBuilder = new CascadesSubjectBuilder(\n subjects,\n )\n subjects.forEach((subject) => {\n // next step we build list of subjects we will operate with\n // these subjects are subjects that we need to insert or update alongside with main persisted entity\n cascadesSubjectBuilder.build(subject, this.mode)\n })\n // console.timeEnd(\"building cascades...\");\n\n // load database entities for all subjects we have\n // next step is to load database entities for all operate subjects\n // console.time(\"loading...\");\n await new SubjectDatabaseEntityLoader(\n queryRunner,\n subjects,\n ).load(this.mode)\n // console.timeEnd(\"loading...\");\n\n // console.time(\"other subjects...\");\n // build all related subjects and change maps\n if (\n this.mode === \"save\" ||\n this.mode === \"soft-remove\" ||\n this.mode === \"recover\"\n ) {\n new OneToManySubjectBuilder(subjects).build()\n new OneToOneInverseSideSubjectBuilder(subjects).build()\n new ManyToManySubjectBuilder(subjects).build()\n } else {\n subjects.forEach((subject) => {\n if (subject.mustBeRemoved) {\n new ManyToManySubjectBuilder(\n subjects,\n ).buildForAllRemoval(subject)\n }\n })\n }\n // console.timeEnd(\"other subjects...\");\n // console.timeEnd(\"building subjects...\");\n // console.log(\"subjects\", subjects);\n\n // create a subject executor\n return new SubjectExecutor(\n queryRunner,\n subjects,\n this.options,\n )\n }),\n )\n // console.timeEnd(\"building subject executors...\");\n\n // make sure we have at least one executable operation before we create a transaction and proceed\n // if we don't have operations it means we don't really need to update or remove something\n const executorsWithExecutableOperations = executors.filter(\n (executor) => executor.hasExecutableOperations,\n )\n if (executorsWithExecutableOperations.length === 0) return\n\n // start execute queries in a transaction\n // if transaction is already opened in this query runner then we don't touch it\n // if its not opened yet then we open it here, and once we finish - we close it\n let isTransactionStartedByUs = false\n try {\n // open transaction if its not opened yet\n if (!queryRunner.isTransactionActive) {\n if (!this.options || this.options.transaction !== false) {\n // start transaction until it was not explicitly disabled\n isTransactionStartedByUs = true\n await queryRunner.startTransaction()\n }\n }\n\n // execute all persistence operations for all entities we have\n // console.time(\"executing subject executors...\");\n for (const executor of executorsWithExecutableOperations) {\n await executor.execute()\n }\n // console.timeEnd(\"executing subject executors...\");\n\n // commit transaction if it was started by us\n // console.time(\"commit\");\n if (isTransactionStartedByUs === true)\n await queryRunner.commitTransaction()\n // console.timeEnd(\"commit\");\n } catch (error) {\n // rollback transaction if it was started by us\n if (isTransactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n throw error\n }\n } finally {\n queryRunner.data = oldQueryRunnerData\n\n // release query runner only if its created by us\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/persistence/EntityPersistExecutor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAA;AAGhF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAA;AACnF,OAAO,EAAE,iCAAiC,EAAE,MAAM,qDAAqD,CAAA;AACvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,4CAA4C,CAAA;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAC9B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EACtB,WAAoC,EACpC,IAAmD,EACnD,MAAqC,EACrC,MAAuC,EACvC,OAAqC;QALr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KAAK,CAAA;aACd;SACJ;gBAAS;YACN,WAAW,CAAC,IAAI,GAAG,kBAAkB,CAAA;YAErC,iDAAiD;YACjD,IAAI,CAAC,IAAI,CAAC,WAAW;gBAAE,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;SACrD;IACL,CAAC;CACJ","file":"EntityPersistExecutor.js","sourcesContent":["import { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport { SaveOptions } from \"../repository/SaveOptions\"\nimport { RemoveOptions } from \"../repository/RemoveOptions\"\nimport { MustBeEntityError } from \"../error/MustBeEntityError\"\nimport { SubjectExecutor } from \"./SubjectExecutor\"\nimport { CannotDetermineEntityError } from \"../error/CannotDetermineEntityError\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { Subject } from \"./Subject\"\nimport { OneToManySubjectBuilder } from \"./subject-builder/OneToManySubjectBuilder\"\nimport { OneToOneInverseSideSubjectBuilder } from \"./subject-builder/OneToOneInverseSideSubjectBuilder\"\nimport { ManyToManySubjectBuilder } from \"./subject-builder/ManyToManySubjectBuilder\"\nimport { SubjectDatabaseEntityLoader } from \"./SubjectDatabaseEntityLoader\"\nimport { CascadesSubjectBuilder } from \"./subject-builder/CascadesSubjectBuilder\"\nimport { OrmUtils } from \"../util/OrmUtils\"\n\n/**\n * Persists a single entity or multiple entities - saves or removes them.\n */\nexport class EntityPersistExecutor {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected connection: DataSource,\n protected queryRunner: QueryRunner | undefined,\n protected mode: \"save\" | \"remove\" | \"soft-remove\" | \"recover\",\n protected target: Function | string | undefined,\n protected entity: ObjectLiteral | ObjectLiteral[],\n protected options?: SaveOptions & RemoveOptions,\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Executes persistence operation ob given entity or entities.\n */\n async execute(): Promise<void> {\n // check if entity we are going to save is valid and is an object\n if (!this.entity || typeof this.entity !== \"object\")\n return Promise.reject(new MustBeEntityError(this.mode, this.entity))\n\n // we MUST call \"fake\" resolve here to make sure all properties of lazily loaded relations are resolved\n await Promise.resolve()\n\n // if query runner is already defined in this class, it means this entity manager was already created for a single connection\n // if its not defined we create a new query runner - single connection where we'll execute all our operations\n const queryRunner =\n this.queryRunner || this.connection.createQueryRunner()\n\n // save data in the query runner - this is useful functionality to share data from outside of the world\n // with third classes - like subscribers and listener methods\n let oldQueryRunnerData = queryRunner.data\n if (this.options && this.options.data) {\n queryRunner.data = this.options.data\n }\n\n try {\n // collect all operate subjects\n const entities: ObjectLiteral[] = Array.isArray(this.entity)\n ? this.entity\n : [this.entity]\n const entitiesInChunks =\n this.options && this.options.chunk && this.options.chunk > 0\n ? OrmUtils.chunk(entities, this.options.chunk)\n : [entities]\n\n // console.time(\"building subject executors...\");\n const executors = await Promise.all(\n entitiesInChunks.map(async (entities) => {\n const subjects: Subject[] = []\n\n // create subjects for all entities we received for the persistence\n entities.forEach((entity) => {\n const entityTarget = this.target\n ? this.target\n : entity.constructor\n if (entityTarget === Object)\n throw new CannotDetermineEntityError(this.mode)\n\n let metadata = this.connection.getMetadata(entityTarget)\n\n // Check for single table inheritance and find the correct metadata in that case.\n // Goal is to use the correct discriminator as we could have a repository\n // for an (abstract) base class and thus the target would not match.\n if (\n metadata.inheritancePattern === \"STI\" &&\n metadata.childEntityMetadatas.length > 0\n ) {\n const matchingChildMetadata =\n metadata.childEntityMetadatas.find(\n (meta) =>\n entity.constructor === meta.target,\n )\n if (matchingChildMetadata) {\n metadata = matchingChildMetadata\n }\n }\n\n subjects.push(\n new Subject({\n metadata,\n entity: entity,\n canBeInserted: this.mode === \"save\",\n canBeUpdated: this.mode === \"save\",\n mustBeRemoved: this.mode === \"remove\",\n canBeSoftRemoved: this.mode === \"soft-remove\",\n canBeRecovered: this.mode === \"recover\",\n }),\n )\n })\n\n // console.time(\"building cascades...\");\n // go through each entity with metadata and create subjects and subjects by cascades for them\n const cascadesSubjectBuilder = new CascadesSubjectBuilder(\n subjects,\n )\n subjects.forEach((subject) => {\n // next step we build list of subjects we will operate with\n // these subjects are subjects that we need to insert or update alongside with main persisted entity\n cascadesSubjectBuilder.build(subject, this.mode)\n })\n // console.timeEnd(\"building cascades...\");\n\n // load database entities for all subjects we have\n // next step is to load database entities for all operate subjects\n // console.time(\"loading...\");\n await new SubjectDatabaseEntityLoader(\n queryRunner,\n subjects,\n ).load(this.mode)\n // console.timeEnd(\"loading...\");\n\n // console.time(\"other subjects...\");\n // build all related subjects and change maps\n if (\n this.mode === \"save\" ||\n this.mode === \"soft-remove\" ||\n this.mode === \"recover\"\n ) {\n new OneToManySubjectBuilder(subjects).build()\n new OneToOneInverseSideSubjectBuilder(subjects).build()\n new ManyToManySubjectBuilder(subjects).build()\n } else {\n subjects.forEach((subject) => {\n if (subject.mustBeRemoved) {\n new ManyToManySubjectBuilder(\n subjects,\n ).buildForAllRemoval(subject)\n }\n })\n }\n // console.timeEnd(\"other subjects...\");\n // console.timeEnd(\"building subjects...\");\n // console.log(\"subjects\", subjects);\n\n // create a subject executor\n return new SubjectExecutor(\n queryRunner,\n subjects,\n this.options,\n )\n }),\n )\n // console.timeEnd(\"building subject executors...\");\n\n // make sure we have at least one executable operation before we create a transaction and proceed\n // if we don't have operations it means we don't really need to update or remove something\n const executorsWithExecutableOperations = executors.filter(\n (executor) => executor.hasExecutableOperations,\n )\n if (executorsWithExecutableOperations.length === 0) return\n\n // start execute queries in a transaction\n // if transaction is already opened in this query runner then we don't touch it\n // if its not opened yet then we open it here, and once we finish - we close it\n let isTransactionStartedByUs = false\n try {\n // open transaction if its not opened yet\n if (!queryRunner.isTransactionActive) {\n if (!this.options || this.options.transaction !== false) {\n // start transaction until it was not explicitly disabled\n isTransactionStartedByUs = true\n await queryRunner.startTransaction()\n }\n }\n\n // execute all persistence operations for all entities we have\n // console.time(\"executing subject executors...\");\n for (const executor of executorsWithExecutableOperations) {\n await executor.execute()\n }\n // console.timeEnd(\"executing subject executors...\");\n\n // commit transaction if it was started by us\n // console.time(\"commit\");\n if (isTransactionStartedByUs === true)\n await queryRunner.commitTransaction()\n // console.timeEnd(\"commit\");\n } catch (error) {\n // rollback transaction if it was started by us\n if (isTransactionStartedByUs) {\n try {\n await queryRunner.rollbackTransaction()\n } catch (rollbackError) {}\n }\n throw error\n }\n } finally {\n queryRunner.data = oldQueryRunnerData\n\n // release query runner only if its created by us\n if (!this.queryRunner) await queryRunner.release()\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -72,6 +72,15 @@ export declare class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
|
|
|
72
72
|
orIgnore(statement?: string | boolean): this;
|
|
73
73
|
/**
|
|
74
74
|
* @deprecated
|
|
75
|
+
*
|
|
76
|
+
* `.orUpdate({ columns: [ "is_updated" ] }).setParameter("is_updated", value)`
|
|
77
|
+
*
|
|
78
|
+
* is now `.orUpdate(["is_updated"])`
|
|
79
|
+
*
|
|
80
|
+
* `.orUpdate({ conflict_target: ['date'], overwrite: ['title'] })`
|
|
81
|
+
*
|
|
82
|
+
* is now `.orUpdate(['title'], ['date'])`
|
|
83
|
+
*
|
|
75
84
|
*/
|
|
76
85
|
orUpdate(statement?: {
|
|
77
86
|
columns?: string[];
|
|
@@ -252,7 +252,7 @@ export class InsertQueryBuilder extends QueryBuilder {
|
|
|
252
252
|
}
|
|
253
253
|
query += `INTO ${tableName}`;
|
|
254
254
|
if (this.alias !== this.getMainTableName() &&
|
|
255
|
-
this.connection.driver
|
|
255
|
+
DriverUtils.isPostgresFamily(this.connection.driver)) {
|
|
256
256
|
query += ` AS "${this.alias}"`;
|
|
257
257
|
}
|
|
258
258
|
// add columns expression
|
|
@@ -324,7 +324,7 @@ export class InsertQueryBuilder extends QueryBuilder {
|
|
|
324
324
|
}
|
|
325
325
|
if (Array.isArray(overwrite) &&
|
|
326
326
|
skipUpdateIfNoValuesChanged &&
|
|
327
|
-
this.connection.driver
|
|
327
|
+
DriverUtils.isPostgresFamily(this.connection.driver)) {
|
|
328
328
|
query += ` WHERE (`;
|
|
329
329
|
query += overwrite
|
|
330
330
|
.map((column) => `${tableName}.${this.escape(column)} IS DISTINCT FROM EXCLUDED.${this.escape(column)}`)
|
|
@@ -360,7 +360,7 @@ export class InsertQueryBuilder extends QueryBuilder {
|
|
|
360
360
|
}
|
|
361
361
|
// add RETURNING expression
|
|
362
362
|
if (returningExpression &&
|
|
363
|
-
(this.connection.driver
|
|
363
|
+
(DriverUtils.isPostgresFamily(this.connection.driver) ||
|
|
364
364
|
this.connection.driver.options.type === "oracle" ||
|
|
365
365
|
this.connection.driver.options.type === "cockroachdb" ||
|
|
366
366
|
DriverUtils.isMySQLFamily(this.connection.driver))) {
|
|
@@ -555,8 +555,7 @@ export class InsertQueryBuilder extends QueryBuilder {
|
|
|
555
555
|
expression += `${geomFromText}(${paramName})`;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
else if (this.connection.driver
|
|
559
|
-
"postgres" &&
|
|
558
|
+
else if (DriverUtils.isPostgresFamily(this.connection.driver) &&
|
|
560
559
|
this.connection.driver.spatialTypes.indexOf(column.type) !== -1) {
|
|
561
560
|
if (column.srid != null) {
|
|
562
561
|
expression += `ST_SetSRID(ST_GeomFromGeoJSON(${paramName}), ${column.srid})::${column.type}`;
|