diff --git a/package-lock.json b/package-lock.json index b14943d1db..30c0663c55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@streamyard/typeorm", - "version": "0.3.16-2", + "version": "0.3.16-3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@streamyard/typeorm", - "version": "0.3.16-2", + "version": "0.3.16-3", "license": "MIT", "dependencies": { "@sqltools/formatter": "^1.2.5", diff --git a/package.json b/package.json index 7826c9f120..1f866d64b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@streamyard/typeorm", "private": true, - "version": "0.3.16-2", + "version": "0.3.16-3", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB, Spanner databases.", "license": "MIT", "readmeFilename": "README.md", diff --git a/src/driver/spanner/SpannerConnectionOptions.ts b/src/driver/spanner/SpannerConnectionOptions.ts index a4ab000cf0..ce3b304fcb 100644 --- a/src/driver/spanner/SpannerConnectionOptions.ts +++ b/src/driver/spanner/SpannerConnectionOptions.ts @@ -1,12 +1,13 @@ import { BaseConnectionOptions } from "../../connection/BaseConnectionOptions" import { SpannerConnectionCredentialsOptions } from "./SpannerConnectionCredentialsOptions" +import { SpannerSessionPoolOptions } from "./SpannerSessionPoolOptions" /** * Spanner specific connection options. */ export interface SpannerConnectionOptions extends BaseConnectionOptions, - SpannerConnectionCredentialsOptions { + SpannerConnectionCredentialsOptions { /** * Database type. */ @@ -146,4 +147,6 @@ export interface SpannerConnectionOptions } readonly poolSize?: never + + readonly sessionPool?: SpannerSessionPoolOptions } diff --git a/src/driver/spanner/SpannerDriver.ts b/src/driver/spanner/SpannerDriver.ts index 025812c47b..a21c50c85b 100644 --- a/src/driver/spanner/SpannerDriver.ts +++ b/src/driver/spanner/SpannerDriver.ts @@ -205,7 +205,7 @@ export class SpannerDriver implements Driver { */ async connect(): Promise { this.instance = this.spanner.instance(this.options.instanceId) - this.instanceDatabase = this.instance.database(this.options.databaseId) + this.instanceDatabase = this.instance.database(this.options.databaseId, this.options.sessionPool ?? {}) } /** @@ -422,9 +422,9 @@ export class SpannerDriver implements Driver { if (value === null || value === undefined) return columnMetadata.transformer ? ApplyValueTransformers.transformFrom( - columnMetadata.transformer, - value, - ) + columnMetadata.transformer, + value, + ) : value if (columnMetadata.type === Boolean || columnMetadata.type === "bool") { diff --git a/src/driver/spanner/SpannerSessionPoolOptions.ts b/src/driver/spanner/SpannerSessionPoolOptions.ts new file mode 100644 index 0000000000..d9291905ab --- /dev/null +++ b/src/driver/spanner/SpannerSessionPoolOptions.ts @@ -0,0 +1,38 @@ +/** + * Spanner specific SessionPool options + * more: https://github.com/ko3a4ok/nodejs-spanner/blob/aa8e8becf74d41d0de68253c17ebab188b5c7620/src/session-pool.ts#L149 + */ +export interface SpannerSessionPoolOptions { + acquireTimeout?: number; + concurrency?: number; + fail?: boolean; + idlesAfter?: number; + keepAlive?: number; + labels?: { [label: string]: string }; + max?: number; + maxIdle?: number; + min?: number; + /** + * @deprecated. Starting from v6.5.0 the same session can be reused for + * different types of transactions. + */ + writes?: number; + incStep?: number; + databaseRole?: string | null; +} + +/* Defaults: + const DEFAULTS: SessionPoolOptions = { + acquireTimeout: Infinity, + concurrency: Infinity, + fail: false, + idlesAfter: 10, + keepAlive: 30, + labels: {}, + max: 100, + maxIdle: 1, + min: 25, + incStep: 25, + databaseRole: null, + }; +*/