sedentary-pg 0.0.48 → 0.0.49
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/dist/cjs/pgdb.js +6 -7
- package/dist/es/pgdb.js +1 -2
- package/dist/types/pgdb.d.ts +1 -2
- package/package.json +2 -2
package/dist/cjs/pgdb.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.TransactionPG = exports.PGDB = void 0;
|
|
|
7
7
|
const pg_1 = require("pg");
|
|
8
8
|
const pg_format_1 = __importDefault(require("pg-format"));
|
|
9
9
|
const sedentary_1 = require("sedentary");
|
|
10
|
-
const db_1 = require("sedentary/db");
|
|
11
10
|
const adsrc_1 = require("./adsrc");
|
|
12
11
|
const needDrop = [
|
|
13
12
|
["DATETIME", "int2"],
|
|
@@ -106,7 +105,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
106
105
|
const value = {};
|
|
107
106
|
for (const attribute in attributes)
|
|
108
107
|
entry[attribute] = value[attribute] = row[attributes[attribute]];
|
|
109
|
-
Object.defineProperty(entry,
|
|
108
|
+
Object.defineProperty(entry, sedentary_1.loaded, { configurable: true, value });
|
|
110
109
|
}
|
|
111
110
|
load(tableName, attributes, pk, model, table) {
|
|
112
111
|
const pkFldName = pk.fieldName;
|
|
@@ -159,7 +158,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
159
158
|
const pkAttrName = pk.attributeName;
|
|
160
159
|
const pkFldName = pk.fieldName;
|
|
161
160
|
return async function () {
|
|
162
|
-
const client = this[
|
|
161
|
+
const client = this[sedentary_1.transaction] ? this[sedentary_1.transaction]._client : await self.pool.connect();
|
|
163
162
|
let removed;
|
|
164
163
|
try {
|
|
165
164
|
const query = `DELETE FROM ${tableName} WHERE ${pkFldName} = ${self.escape(this[pkAttrName])}`;
|
|
@@ -167,7 +166,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
167
166
|
removed = (await client.query(query)).rowCount;
|
|
168
167
|
}
|
|
169
168
|
finally {
|
|
170
|
-
if (!this[
|
|
169
|
+
if (!this[sedentary_1.transaction])
|
|
171
170
|
client.release();
|
|
172
171
|
}
|
|
173
172
|
return removed;
|
|
@@ -179,7 +178,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
179
178
|
const pkAttrName = pk.attributeName;
|
|
180
179
|
const pkFldName = pk.fieldName;
|
|
181
180
|
return async function () {
|
|
182
|
-
const client = this[
|
|
181
|
+
const client = this[sedentary_1.transaction] ? this[sedentary_1.transaction]._client : await self.pool.connect();
|
|
183
182
|
let changed = false;
|
|
184
183
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
184
|
let result = null;
|
|
@@ -190,7 +189,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
190
189
|
self.fill(attributes, result.rows[0], this);
|
|
191
190
|
};
|
|
192
191
|
try {
|
|
193
|
-
const loadedRecord = this[
|
|
192
|
+
const loadedRecord = this[sedentary_1.loaded];
|
|
194
193
|
if (loadedRecord) {
|
|
195
194
|
const actions = [];
|
|
196
195
|
for (const attribute in attributes) {
|
|
@@ -215,7 +214,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
215
214
|
}
|
|
216
215
|
}
|
|
217
216
|
finally {
|
|
218
|
-
if (!this[
|
|
217
|
+
if (!this[sedentary_1.transaction])
|
|
219
218
|
client.release();
|
|
220
219
|
}
|
|
221
220
|
return changed && result.rowCount;
|
package/dist/es/pgdb.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DatabaseError, Pool, types as PGtypes } from "pg";
|
|
2
2
|
import format from "pg-format";
|
|
3
|
-
import { DB, differ, Transaction } from "sedentary";
|
|
4
|
-
import { loaded, transaction } from "sedentary/db";
|
|
3
|
+
import { DB, differ, loaded, Transaction, transaction } from "sedentary";
|
|
5
4
|
import { adsrc } from "./adsrc";
|
|
6
5
|
const needDrop = [
|
|
7
6
|
["DATETIME", "int2"],
|
package/dist/types/pgdb.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PoolClient, PoolConfig } from "pg";
|
|
2
|
-
import { Attribute, DB, EntryBase, Table, Transaction } from "sedentary";
|
|
3
|
-
import { loaded, transaction } from "sedentary/db";
|
|
2
|
+
import { Attribute, DB, EntryBase, loaded, Table, Transaction, transaction } from "sedentary";
|
|
4
3
|
export declare class PGDB extends DB<TransactionPG> {
|
|
5
4
|
private _client;
|
|
6
5
|
private indexes;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"@types/pg": "8.6.5",
|
|
10
10
|
"pg": "8.8.0",
|
|
11
11
|
"pg-format": "1.0.4",
|
|
12
|
-
"sedentary": "0.0.
|
|
12
|
+
"sedentary": "0.0.49"
|
|
13
13
|
},
|
|
14
14
|
"description": "The ORM which never needs to migrate - PostgreSQL",
|
|
15
15
|
"engines": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"test": "jest --no-cache --runInBand"
|
|
48
48
|
},
|
|
49
49
|
"types": "./dist/types/index.d.ts",
|
|
50
|
-
"version": "0.0.
|
|
50
|
+
"version": "0.0.49"
|
|
51
51
|
}
|