typeorm 0.3.5-dev.eacecce → 0.3.5
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 -1
- 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/DataSource.js +2 -5
- package/browser/data-source/DataSource.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/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/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/cli.js +0 -0
- 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/DataSource.js +17 -20
- package/data-source/DataSource.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/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/index.mjs +6 -0
- package/package.json +261 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":";;;AAAA,kFAA8E;AAE9E,yDAAqD;AAGrD,+FAA2F;AAC3F,iFAA6E;AAC7E,gEAA4D;AAE5D,kDAA8C;AAG9C,uCAA0C;AAS1C,MAAa,WAAY,SAAQ,2CAAoB;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,iDAAuB,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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,eAAe,GAAG,OAAO,IAAI,CAAC,MAAM,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,6BAAa,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,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;aACvB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,+DAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;aAC/D;SACJ;IACL,CAAC;CACJ;AAhSD,kCAgSC","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":["../../src/driver/sqljs/SqljsDriver.ts"],"names":[],"mappings":";;;AAAA,kFAA8E;AAE9E,yDAAqD;AAGrD,+FAA2F;AAC3F,iFAA6E;AAC7E,gEAA4D;AAE5D,kDAA8C;AAG9C,uCAA0C;AAS1C,MAAa,WAAY,SAAQ,2CAAoB;IAIjD,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAY,UAAsB;QAC9B,KAAK,CAAC,UAAU,CAAC,CAAA;QAEjB,8EAA8E;QAC9E,u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AI;gBACA,MAAM,MAAM,GACR,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,6BAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;aACvB;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,+DAA8B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;aAC/D;SACJ;IACL,CAAC;CACJ;AAhSD,kCAgSC","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":"../.."}
|
package/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/index.js
CHANGED
|
@@ -68,6 +68,9 @@ tslib_1.__exportStar(require("./decorator/Exclusion"), exports);
|
|
|
68
68
|
tslib_1.__exportStar(require("./decorator/Generated"), exports);
|
|
69
69
|
tslib_1.__exportStar(require("./decorator/EntityRepository"), exports);
|
|
70
70
|
tslib_1.__exportStar(require("./find-options/operator/Any"), exports);
|
|
71
|
+
tslib_1.__exportStar(require("./find-options/operator/ArrayContainedBy"), exports);
|
|
72
|
+
tslib_1.__exportStar(require("./find-options/operator/ArrayContains"), exports);
|
|
73
|
+
tslib_1.__exportStar(require("./find-options/operator/ArrayOverlap"), exports);
|
|
71
74
|
tslib_1.__exportStar(require("./find-options/operator/Between"), exports);
|
|
72
75
|
tslib_1.__exportStar(require("./find-options/operator/Equal"), exports);
|
|
73
76
|
tslib_1.__exportStar(require("./find-options/operator/In"), exports);
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA;GACG;AACH,4BAAyB;AAEzB,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,oDAAyB;AACzB,sDAA2B;AAC3B,gEAAqC;AACrC,8DAAmC;AACnC,iEAAsC;AACtC,6DAAkC;AAClC,+DAAoC;AACpC,gEAAqC;AACrC,kDAAuB;AACvB,qEAA0C;AAC1C,+EAAoD;AACpD,+EAAoD;AACpD,qFAA0D;AAC1D,4EAAiD;AACjD,+EAAoD;AACpD,4EAAiD;AACjD,yEAA8C;AAC9C,6EAAkD;AAClD,4EAAiD;AACjD,0EAA+C;AAC/C,4EAAiD;AACjD,gFAAqD;AACrD,6EAAkD;AAClD,4EAAiD;AACjD,6EAAkD;AAClD,6EAAkD;AAClD,iFAAsD;AACtD,8EAAmD;AACnD,6EAAkD;AAClD,gFAAqD;AACrD,4EAAiD;AACjD,2EAAgD;AAChD,gFAAqD;AACrD,+EAAoD;AACpD,8EAAmD;AACnD,4EAAiD;AACjD,+EAAoD;AACpD,2EAAgD;AAChD,0EAA+C;AAC/C,2EAAgD;AAChD,0EAA+C;AAC/C,0EAA+C;AAC/C,yEAA8C;AAC9C,8EAAmD;AACnD,2EAAgD;AAChD,oEAAyC;AACzC,yEAA8C;AAC9C,8EAAmD;AACnD,6EAAkD;AAClD,2EAAgD;AAChD,sEAA2C;AAC3C,wEAA6C;AAC7C,gEAAqC;AACrC,4DAAiC;AACjC,6DAAkC;AAClC,4DAAiC;AACjC,gEAAqC;AACrC,gEAAqC;AACrC,uEAA4C;AAC5C,sEAA2C;AAC3C,0EAA+C;AAC/C,wEAA6C;AAC7C,qEAA0C;AAC1C,yEAA8C;AAC9C,2EAAgD;AAChD,kFAAuD;AAC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A;AAC7B,qDAAmD;AAA1C,oGAAA,QAAQ,OAAA;AACjB,2DAAyD;AAAhD,0GAAA,WAAW,OAAA;AAGpB,oEAAkE;AAAzD,4GAAA,YAAY,OAAA;AACrB,oEAAkE;AAAzD,4GAAA,YAAY,OAAA;AACrB,oEAAkE;AAAzD,4GAAA,YAAY,OAAA;AACrB,0DAAwD;AAA/C,0GAAA,WAAW,OAAA;AAEpB,0EAAwE;AAA/D,wHAAA,kBAAkB,OAAA;AAC3B,mDAAiD;AAAxC,sGAAA,SAAS,OAAA;AAClB,mEAAiE;AAAxD,sHAAA,iBAAiB,OAAA;AAE1B,iFAA+E;AAAtE,8HAAA,qBAAqB,OAAA;AAU9B,6DAA2D;AAAlD,4GAAA,YAAY,OAAA;AAIrB,uGAAqG;AAA5F,sJAAA,iCAAiC,OAAA;AAE1C,2EAAyE;AAAhE,0HAAA,mBAAmB,OAAA;AAC5B,0DAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,kEAAgE;AAAvD,0HAAA,mBAAmB,OAAA","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":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA;GACG;AACH,4BAAyB;AAEzB,4EAA4E;AAC5E,wBAAwB;AACxB,4EAA4E;AAE5E,oDAAyB;AACzB,sDAA2B;AAC3B,gEAAqC;AACrC,8DAAmC;AACnC,iEAAsC;AACtC,6DAAkC;AAClC,+DAAoC;AACpC,gEAAqC;AACrC,kDAAuB;AACvB,qEAA0C;AAC1C,+EAAoD;AACpD,+EAAoD;AACpD,qFAA0D;AAC1D,4EAAiD;AACjD,+EAAoD;AAC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6DAA2D;AAAlD,4GAAA,YAAY,OAAA;AAIrB,uGAAqG;AAA5F,sJAAA,iCAAiC,OAAA;AAE1C,2EAAyE;AAAhE,0HAAA,mBAAmB,OAAA;AAC5B,0DAAwD;AAA/C,kHAAA,eAAe,OAAA;AACxB,kEAAgE;AAAvD,0HAAA,mBAAmB,OAAA","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":"."}
|
package/index.mjs
CHANGED
|
@@ -146,6 +146,9 @@ const {
|
|
|
146
146
|
Generated,
|
|
147
147
|
EntityRepository,
|
|
148
148
|
Any,
|
|
149
|
+
ArrayContainedBy,
|
|
150
|
+
ArrayContains,
|
|
151
|
+
ArrayOverlap,
|
|
149
152
|
Between,
|
|
150
153
|
Equal,
|
|
151
154
|
In,
|
|
@@ -327,6 +330,9 @@ export {
|
|
|
327
330
|
Generated,
|
|
328
331
|
EntityRepository,
|
|
329
332
|
Any,
|
|
333
|
+
ArrayContainedBy,
|
|
334
|
+
ArrayContains,
|
|
335
|
+
ArrayOverlap,
|
|
330
336
|
Between,
|
|
331
337
|
Equal,
|
|
332
338
|
In,
|
package/package.json
CHANGED
|
@@ -1 +1,261 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "typeorm",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.3.5",
|
|
5
|
+
"description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"readmeFilename": "README.md",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Umed Khudoiberdiev",
|
|
10
|
+
"email": "pleerock.me@gmail.com"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">= 12.9.0"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"node": {
|
|
18
|
+
"import": "./index.mjs",
|
|
19
|
+
"require": "./index.js"
|
|
20
|
+
},
|
|
21
|
+
"browser": {
|
|
22
|
+
"require": "./index.js",
|
|
23
|
+
"import": "./browser/index.js",
|
|
24
|
+
"default": "./index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./browser": "./browser/index.js",
|
|
28
|
+
"./*.js": "./*.js",
|
|
29
|
+
"./*": {
|
|
30
|
+
"require": "./*.js",
|
|
31
|
+
"import": "./*"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"main": "./index.js",
|
|
35
|
+
"module": "./index.mjs",
|
|
36
|
+
"types": "./index.d.ts",
|
|
37
|
+
"browser": {
|
|
38
|
+
"./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
39
|
+
"./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
40
|
+
"./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
|
|
41
|
+
"./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
42
|
+
"./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
43
|
+
"./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
44
|
+
"./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
45
|
+
"./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
46
|
+
"./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
47
|
+
"./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
48
|
+
"./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
49
|
+
"./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
50
|
+
"./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
51
|
+
"./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
52
|
+
"./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
53
|
+
"./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js",
|
|
54
|
+
"./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js",
|
|
55
|
+
"./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js",
|
|
56
|
+
"./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js",
|
|
57
|
+
"./index.js": "./browser/index.js",
|
|
58
|
+
"./index.mjs": "./browser/index.js"
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "https://github.com/typeorm/typeorm.git"
|
|
63
|
+
},
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/typeorm/typeorm/issues"
|
|
66
|
+
},
|
|
67
|
+
"tags": [
|
|
68
|
+
"orm",
|
|
69
|
+
"typescript",
|
|
70
|
+
"typescript-orm",
|
|
71
|
+
"mysql",
|
|
72
|
+
"mysql-orm",
|
|
73
|
+
"postgresql",
|
|
74
|
+
"postgresql-orm",
|
|
75
|
+
"mariadb",
|
|
76
|
+
"mariadb-orm",
|
|
77
|
+
"sqlite",
|
|
78
|
+
"sqlite-orm",
|
|
79
|
+
"sql-server",
|
|
80
|
+
"sql-server-orm",
|
|
81
|
+
"oracle",
|
|
82
|
+
"oracle-orm"
|
|
83
|
+
],
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@types/app-root-path": "^1.2.4",
|
|
86
|
+
"@types/chai": "^4.2.15",
|
|
87
|
+
"@types/chai-as-promised": "^7.1.3",
|
|
88
|
+
"@types/debug": "^4.1.5",
|
|
89
|
+
"@types/js-yaml": "^4.0.0",
|
|
90
|
+
"@types/mkdirp": "^1.0.1",
|
|
91
|
+
"@types/mocha": "^8.2.1",
|
|
92
|
+
"@types/node": "^14.14.31",
|
|
93
|
+
"@types/rimraf": "^3.0.0",
|
|
94
|
+
"@types/sha.js": "^2.4.0",
|
|
95
|
+
"@types/sinon": "^9.0.10",
|
|
96
|
+
"@types/source-map-support": "^0.5.3",
|
|
97
|
+
"@types/uuid": "^8.3.4",
|
|
98
|
+
"@types/xml2js": "^0.4.8",
|
|
99
|
+
"@types/yargs": "^17.0.2",
|
|
100
|
+
"better-sqlite3": "^7.1.2",
|
|
101
|
+
"chai": "^4.3.0",
|
|
102
|
+
"chai-as-promised": "^7.1.1",
|
|
103
|
+
"class-transformer": "^0.4.0",
|
|
104
|
+
"conventional-changelog-angular": "^5.0.12",
|
|
105
|
+
"conventional-changelog-cli": "^2.1.1",
|
|
106
|
+
"del": "^6.0.0",
|
|
107
|
+
"gulp": "^4.0.2",
|
|
108
|
+
"gulp-istanbul": "^1.1.3",
|
|
109
|
+
"gulp-mocha": "^8.0.0",
|
|
110
|
+
"gulp-rename": "^2.0.0",
|
|
111
|
+
"gulp-replace": "^1.0.0",
|
|
112
|
+
"gulp-shell": "^0.8.0",
|
|
113
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
114
|
+
"gulp-typescript": "^6.0.0-alpha.1",
|
|
115
|
+
"gulpclass": "^0.2.0",
|
|
116
|
+
"husky": "^5.1.1",
|
|
117
|
+
"mocha": "^8.3.0",
|
|
118
|
+
"mongodb": "^3.6.4",
|
|
119
|
+
"mssql": "^7.3.0",
|
|
120
|
+
"mysql": "^2.18.1",
|
|
121
|
+
"mysql2": "^2.2.5",
|
|
122
|
+
"pg": "^8.5.1",
|
|
123
|
+
"pg-query-stream": "^4.0.0",
|
|
124
|
+
"redis": "^3.1.1",
|
|
125
|
+
"remap-istanbul": "^0.13.0",
|
|
126
|
+
"rimraf": "^3.0.2",
|
|
127
|
+
"sinon": "^9.2.4",
|
|
128
|
+
"sinon-chai": "^3.5.0",
|
|
129
|
+
"source-map-support": "^0.5.19",
|
|
130
|
+
"sql.js": "^1.4.0",
|
|
131
|
+
"sqlite3": "^5.0.2",
|
|
132
|
+
"ts-node": "^10.7.0",
|
|
133
|
+
"typeorm-aurora-data-api-driver": "^2.0.0",
|
|
134
|
+
"typescript": "^4.6.2",
|
|
135
|
+
"prettier": "^2.5.1"
|
|
136
|
+
},
|
|
137
|
+
"peerDependencies": {
|
|
138
|
+
"@sap/hana-client": "^2.11.14",
|
|
139
|
+
"better-sqlite3": "^7.1.2",
|
|
140
|
+
"hdb-pool": "^0.1.6",
|
|
141
|
+
"ioredis": "^4.28.3",
|
|
142
|
+
"mongodb": "^3.6.0",
|
|
143
|
+
"mssql": "^6.3.1",
|
|
144
|
+
"mysql2": "^2.2.5",
|
|
145
|
+
"oracledb": "^5.1.0",
|
|
146
|
+
"pg": "^8.5.1",
|
|
147
|
+
"pg-native": "^3.0.0",
|
|
148
|
+
"pg-query-stream": "^4.0.0",
|
|
149
|
+
"redis": "^3.1.1",
|
|
150
|
+
"sql.js": "^1.4.0",
|
|
151
|
+
"sqlite3": "^5.0.2",
|
|
152
|
+
"ts-node": "^10.7.0",
|
|
153
|
+
"typeorm-aurora-data-api-driver": "^2.0.0"
|
|
154
|
+
},
|
|
155
|
+
"peerDependenciesMeta": {
|
|
156
|
+
"@sap/hana-client": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"better-sqlite3": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"hdb-pool": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"ioredis": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"mongodb": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"mssql": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"mysql2": {
|
|
175
|
+
"optional": true
|
|
176
|
+
},
|
|
177
|
+
"oracledb": {
|
|
178
|
+
"optional": true
|
|
179
|
+
},
|
|
180
|
+
"pg": {
|
|
181
|
+
"optional": true
|
|
182
|
+
},
|
|
183
|
+
"pg-native": {
|
|
184
|
+
"optional": true
|
|
185
|
+
},
|
|
186
|
+
"pg-query-stream": {
|
|
187
|
+
"optional": true
|
|
188
|
+
},
|
|
189
|
+
"redis": {
|
|
190
|
+
"optional": true
|
|
191
|
+
},
|
|
192
|
+
"sql.js": {
|
|
193
|
+
"optional": true
|
|
194
|
+
},
|
|
195
|
+
"sqlite3": {
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
"ts-node": {
|
|
199
|
+
"optional": true
|
|
200
|
+
},
|
|
201
|
+
"typeorm-aurora-data-api-driver": {
|
|
202
|
+
"optional": true
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
"dependencies": {
|
|
206
|
+
"@sqltools/formatter": "^1.2.2",
|
|
207
|
+
"app-root-path": "^3.0.0",
|
|
208
|
+
"buffer": "^6.0.3",
|
|
209
|
+
"chalk": "^4.1.0",
|
|
210
|
+
"cli-highlight": "^2.1.11",
|
|
211
|
+
"debug": "^4.3.3",
|
|
212
|
+
"dotenv": "^16.0.0",
|
|
213
|
+
"glob": "^7.2.0",
|
|
214
|
+
"js-yaml": "^4.1.0",
|
|
215
|
+
"mkdirp": "^1.0.4",
|
|
216
|
+
"reflect-metadata": "^0.1.13",
|
|
217
|
+
"sha.js": "^2.4.11",
|
|
218
|
+
"tslib": "^2.3.1",
|
|
219
|
+
"uuid": "^8.3.2",
|
|
220
|
+
"xml2js": "^0.4.23",
|
|
221
|
+
"yargs": "^17.3.1",
|
|
222
|
+
"date-fns": "^2.28.0"
|
|
223
|
+
},
|
|
224
|
+
"scripts": {
|
|
225
|
+
"test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test",
|
|
226
|
+
"test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test",
|
|
227
|
+
"compile": "rimraf ./build && tsc",
|
|
228
|
+
"watch": "./node_modules/.bin/tsc -w",
|
|
229
|
+
"package": "gulp package",
|
|
230
|
+
"pack": "gulp pack",
|
|
231
|
+
"lint": "prettier --check \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
|
|
232
|
+
"format": "prettier --write \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
|
|
233
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2"
|
|
234
|
+
},
|
|
235
|
+
"bin": {
|
|
236
|
+
"typeorm": "./cli.js",
|
|
237
|
+
"typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js",
|
|
238
|
+
"typeorm-ts-node-esm": "./cli-ts-node-esm.js"
|
|
239
|
+
},
|
|
240
|
+
"funding": "https://opencollective.com/typeorm",
|
|
241
|
+
"collective": {
|
|
242
|
+
"type": "opencollective",
|
|
243
|
+
"url": "https://opencollective.com/typeorm",
|
|
244
|
+
"logo": "https://opencollective.com/opencollective/logo.txt"
|
|
245
|
+
},
|
|
246
|
+
"nyc": {
|
|
247
|
+
"all": true,
|
|
248
|
+
"cache": false,
|
|
249
|
+
"exclude": [
|
|
250
|
+
"**/*.d.ts"
|
|
251
|
+
],
|
|
252
|
+
"extension": [
|
|
253
|
+
".ts"
|
|
254
|
+
],
|
|
255
|
+
"include": [
|
|
256
|
+
"build/compiled/src/**",
|
|
257
|
+
"src/**"
|
|
258
|
+
],
|
|
259
|
+
"reporter": "json"
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -65,8 +65,19 @@ class EntityPersistExecutor {
|
|
|
65
65
|
: entity.constructor;
|
|
66
66
|
if (entityTarget === Object)
|
|
67
67
|
throw new CannotDetermineEntityError_1.CannotDetermineEntityError(this.mode);
|
|
68
|
+
let metadata = this.connection.getMetadata(entityTarget);
|
|
69
|
+
// Check for single table inheritance and find the correct metadata in that case.
|
|
70
|
+
// Goal is to use the correct discriminator as we could have a repository
|
|
71
|
+
// for an (abstract) base class and thus the target would not match.
|
|
72
|
+
if (metadata.inheritancePattern === "STI" &&
|
|
73
|
+
metadata.childEntityMetadatas.length > 0) {
|
|
74
|
+
const matchingChildMetadata = metadata.childEntityMetadatas.find((meta) => entity.constructor === meta.target);
|
|
75
|
+
if (matchingChildMetadata) {
|
|
76
|
+
metadata = matchingChildMetadata;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
68
79
|
subjects.push(new Subject_1.Subject({
|
|
69
|
-
metadata
|
|
80
|
+
metadata,
|
|
70
81
|
entity: entity,
|
|
71
82
|
canBeInserted: this.mode === "save",
|
|
72
83
|
canBeUpdated: this.mode === "save",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/persistence/EntityPersistExecutor.ts"],"names":[],"mappings":";;;AAGA,kEAA8D;AAC9D,uDAAmD;AACnD,oFAAgF;AAGhF,uCAAmC;AACnC,uFAAmF;AACnF,2GAAuG;AACvG,yFAAqF;AACrF,+EAA2E;AAC3E,qFAAiF;AACjF,+CAA2C;AAE3C;;GAEG;AACH,MAAa,qBAAqB;IAC9B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,UAAsB,EAC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AuB,CACjD,CAAA;YACD,IAAI,iCAAiC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAM;YAE1D,yCAAyC;YACzC,+EAA+E;YAC/E,+EAA+E;YAC/E,IAAI,wBAAwB,GAAG,KAAK,CAAA;YACpC,IAAI;gBACA,yCAAyC;gBACzC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE;oBAClC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE;wBACrD,yDAAyD;wBACzD,wBAAwB,GAAG,IAAI,CAAA;wBAC/B,MAAM,WAAW,CAAC,gBAAgB,EAAE,CAAA;qBACvC;iBACJ;gBAED,8DAA8D;gBAC9D,kDAAkD;gBAClD,KAAK,MAAM,QAAQ,IAAI,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;AArLD,sDAqLC","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":["../../src/persistence/EntityPersistExecutor.ts"],"names":[],"mappings":";;;AAGA,kEAA8D;AAC9D,uDAAmD;AACnD,oFAAgF;AAGhF,uCAAmC;AACnC,uFAAmF;AACnF,2GAAuG;AACvG,yFAAqF;AACrF,+EAA2E;AAC3E,qFAAiF;AACjF,+CAA2C;AAE3C;;GAEG;AACH,MAAa,qBAAqB;IAC9B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wB,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;AAvMD,sDAuMC","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[];
|