@pi-r/postgres 0.2.8 → 0.3.2
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/LICENSE +1 -1
- package/README.md +1 -1
- package/client/index.d.ts +2 -1
- package/client/index.js +3 -4
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Studio Trigger
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
package/client/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IDb } from '@e-mc/types/lib';
|
|
2
|
-
import type { PostgresCredential, PostgresDataSource } from '@e-mc/types/lib/db';
|
|
3
2
|
|
|
4
3
|
import type { IDbSourceClient } from '@e-mc/db/types';
|
|
5
4
|
|
|
5
|
+
import type { PostgresCredential, PostgresDataSource } from '../types';
|
|
6
|
+
|
|
6
7
|
declare const Postgres: IDbSourceClient<PostgresDataSource> & {
|
|
7
8
|
setAuthentication(this: IDb, credential: PostgresCredential): void;
|
|
8
9
|
};
|
package/client/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = exports.setAuthentication = void 0;
|
|
4
|
+
const postgres = require("pg");
|
|
4
5
|
const util_1 = require("@e-mc/db/util");
|
|
5
6
|
const types_1 = require("@e-mc/types");
|
|
6
7
|
const Db = require("@e-mc/db");
|
|
@@ -85,7 +86,6 @@ function setCredential(item) {
|
|
|
85
86
|
}
|
|
86
87
|
const poolKey = getPoolKey(credential);
|
|
87
88
|
if (!(pool = POOL_STATE[poolKey]) || pool.closed) {
|
|
88
|
-
const { Pool } = require("pg");
|
|
89
89
|
const config = this.getPoolConfig("postgres", password);
|
|
90
90
|
if (config) {
|
|
91
91
|
const { min, max, idle } = config;
|
|
@@ -99,7 +99,7 @@ function setCredential(item) {
|
|
|
99
99
|
credential.idleTimeoutMillis ?? (credential.idleTimeoutMillis = idle);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
new PostgresPool(new Pool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
102
|
+
new PostgresPool(new postgres.Pool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
105
|
pool.add(item);
|
|
@@ -119,7 +119,6 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
119
119
|
if (length === 0) {
|
|
120
120
|
return [];
|
|
121
121
|
}
|
|
122
|
-
const db = require("pg");
|
|
123
122
|
let parallel, connectOnce, errorQuery, sessionKey, outCacheMiss;
|
|
124
123
|
if ((0, types_1.isPlainObject)(options)) {
|
|
125
124
|
({ parallel, connectOnce, errorQuery, sessionKey, outCacheMiss } = options);
|
|
@@ -183,7 +182,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
183
182
|
}
|
|
184
183
|
}
|
|
185
184
|
if (!client) {
|
|
186
|
-
clients.push(client = new
|
|
185
|
+
clients.push(client = new postgres.Client((postgresCredential || credential)));
|
|
187
186
|
await client.connect();
|
|
188
187
|
}
|
|
189
188
|
if (connectOnce) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/postgres",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "PostgreSQL client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@e-mc/db": "^0.
|
|
25
|
-
"@e-mc/types": "^0.
|
|
24
|
+
"@e-mc/db": "^0.6.1",
|
|
25
|
+
"@e-mc/types": "^0.6.1",
|
|
26
26
|
"pg": "^8.11.3"
|
|
27
27
|
}
|
|
28
28
|
}
|