@travetto/model-postgres 4.0.0-rc.3 → 4.0.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-postgres",
3
- "version": "4.0.0-rc.3",
3
+ "version": "4.0.0-rc.5",
4
4
  "description": "PostgreSQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
5
5
  "keywords": [
6
6
  "sql",
@@ -27,16 +27,16 @@
27
27
  "directory": "module/model-postgres"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/config": "^4.0.0-rc.3",
31
- "@travetto/context": "^4.0.0-rc.3",
32
- "@travetto/model": "^4.0.0-rc.3",
33
- "@travetto/model-query": "^4.0.0-rc.3",
34
- "@travetto/model-sql": "^4.0.0-rc.3",
30
+ "@travetto/config": "^4.0.0-rc.5",
31
+ "@travetto/context": "^4.0.0-rc.5",
32
+ "@travetto/model": "^4.0.0-rc.5",
33
+ "@travetto/model-query": "^4.0.0-rc.5",
34
+ "@travetto/model-sql": "^4.0.0-rc.5",
35
35
  "@types/pg": "^8.11.0",
36
36
  "pg": "^8.11.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "@travetto/command": "^4.0.0-rc.3"
39
+ "@travetto/command": "^4.0.0-rc.5"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@travetto/command": {
package/src/connection.ts CHANGED
@@ -1,4 +1,4 @@
1
- import pg from 'pg';
1
+ import { Pool, PoolClient } from 'pg';
2
2
 
3
3
  import { ShutdownManager } from '@travetto/base';
4
4
  import { AsyncContext, WithAsyncContext } from '@travetto/context';
@@ -9,9 +9,9 @@ import { SQLModelConfig, Connection } from '@travetto/model-sql';
9
9
  /**
10
10
  * Connection support for postgresql
11
11
  */
12
- export class PostgreSQLConnection extends Connection<pg.PoolClient> {
12
+ export class PostgreSQLConnection extends Connection<PoolClient> {
13
13
 
14
- #pool: pg.Pool;
14
+ #pool: Pool;
15
15
  #config: SQLModelConfig;
16
16
 
17
17
  constructor(
@@ -27,7 +27,7 @@ export class PostgreSQLConnection extends Connection<pg.PoolClient> {
27
27
  */
28
28
  @WithAsyncContext()
29
29
  async init(): Promise<void> {
30
- this.#pool = new pg.Pool({
30
+ this.#pool = new Pool({
31
31
  user: this.#config.user,
32
32
  password: this.#config.password,
33
33
  database: this.#config.database,
@@ -48,7 +48,7 @@ export class PostgreSQLConnection extends Connection<pg.PoolClient> {
48
48
  ShutdownManager.onGracefulShutdown(() => this.#pool.end(), this);
49
49
  }
50
50
 
51
- async execute<T = unknown>(conn: pg.PoolClient, query: string): Promise<{ count: number, records: T[] }> {
51
+ async execute<T = unknown>(conn: PoolClient, query: string): Promise<{ count: number, records: T[] }> {
52
52
  console.debug('Executing query', { query });
53
53
  try {
54
54
  const out = await conn.query(query);
@@ -63,11 +63,11 @@ export class PostgreSQLConnection extends Connection<pg.PoolClient> {
63
63
  }
64
64
  }
65
65
 
66
- acquire(): Promise<pg.PoolClient> {
66
+ acquire(): Promise<PoolClient> {
67
67
  return this.#pool.connect();
68
68
  }
69
69
 
70
- release(conn: pg.PoolClient): void {
70
+ release(conn: PoolClient): void {
71
71
  conn.release();
72
72
  }
73
73
  }