sedentary-pg 0.0.39 → 0.0.42
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 +1 -1
- package/dist/cjs/adsrc.js +2 -0
- package/dist/cjs/pgdb.js +4 -3
- package/dist/es/adsrc.js +2 -0
- package/dist/es/pgdb.js +4 -3
- package/dist/types/pgdb.d.ts +1 -1
- package/package.json +14 -51
package/README.md
CHANGED
package/dist/cjs/adsrc.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.adsrc = void 0;
|
|
4
|
+
// cspell: disable-next-line
|
|
4
5
|
function adsrc(version) {
|
|
6
|
+
// cspell: disable-next-line
|
|
5
7
|
return version >= 12 ? "pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid) AS adsrc" : "adsrc";
|
|
6
8
|
}
|
|
7
9
|
exports.adsrc = adsrc;
|
package/dist/cjs/pgdb.js
CHANGED
|
@@ -86,15 +86,16 @@ class PGDB extends sedentary_1.DB {
|
|
|
86
86
|
}
|
|
87
87
|
load(tableName, attributes, pk, model, table) {
|
|
88
88
|
const pkFldName = pk.fieldName;
|
|
89
|
-
return async (where, order, tx, lock) => {
|
|
89
|
+
return async (where, order, limit, tx, lock) => {
|
|
90
90
|
const { oid } = table;
|
|
91
91
|
const ret = [];
|
|
92
92
|
const client = tx ? tx._client : await this.pool.connect();
|
|
93
93
|
const oidPK = {};
|
|
94
94
|
try {
|
|
95
95
|
const forUpdate = lock ? " FOR UPDATE" : "";
|
|
96
|
-
const orderBy = order && order.length ? ` ORDER BY ${order.map(_ => (_.startsWith("-") ? `${_.substring(1)} DESC` : _)).join(",")}` : "";
|
|
97
|
-
const
|
|
96
|
+
const orderBy = order && order.length ? ` ORDER BY ${(typeof order === "string" ? [order] : order).map(_ => (_.startsWith("-") ? `${_.substring(1)} DESC` : _)).join(",")}` : "";
|
|
97
|
+
const limitTo = typeof limit === "number" ? ` LIMIT ${limit}` : "";
|
|
98
|
+
const query = `SELECT *, tableoid FROM ${tableName}${where ? ` WHERE ${where}` : ""}${orderBy}${limitTo}${forUpdate}`;
|
|
98
99
|
this.log(query);
|
|
99
100
|
const res = await client.query(query);
|
|
100
101
|
for (const row of res.rows) {
|
package/dist/es/adsrc.js
CHANGED
package/dist/es/pgdb.js
CHANGED
|
@@ -81,15 +81,16 @@ export class PGDB extends DB {
|
|
|
81
81
|
}
|
|
82
82
|
load(tableName, attributes, pk, model, table) {
|
|
83
83
|
const pkFldName = pk.fieldName;
|
|
84
|
-
return async (where, order, tx, lock) => {
|
|
84
|
+
return async (where, order, limit, tx, lock) => {
|
|
85
85
|
const { oid } = table;
|
|
86
86
|
const ret = [];
|
|
87
87
|
const client = tx ? tx._client : await this.pool.connect();
|
|
88
88
|
const oidPK = {};
|
|
89
89
|
try {
|
|
90
90
|
const forUpdate = lock ? " FOR UPDATE" : "";
|
|
91
|
-
const orderBy = order && order.length ? ` ORDER BY ${order.map(_ => (_.startsWith("-") ? `${_.substring(1)} DESC` : _)).join(",")}` : "";
|
|
92
|
-
const
|
|
91
|
+
const orderBy = order && order.length ? ` ORDER BY ${(typeof order === "string" ? [order] : order).map(_ => (_.startsWith("-") ? `${_.substring(1)} DESC` : _)).join(",")}` : "";
|
|
92
|
+
const limitTo = typeof limit === "number" ? ` LIMIT ${limit}` : "";
|
|
93
|
+
const query = `SELECT *, tableoid FROM ${tableName}${where ? ` WHERE ${where}` : ""}${orderBy}${limitTo}${forUpdate}`;
|
|
93
94
|
this.log(query);
|
|
94
95
|
const res = await client.query(query);
|
|
95
96
|
for (const row of res.rows) {
|
package/dist/types/pgdb.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class PGDB extends DB<TransactionPG> {
|
|
|
15
15
|
client(): Promise<PoolClient>;
|
|
16
16
|
escape(value: Natural): string;
|
|
17
17
|
fill(attributes: Record<string, string>, row: Record<string, Natural>, entry: Record<string, Natural>): void;
|
|
18
|
-
load(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>, model: new (from: "load") => EntryBase, table: Table): (where: string, order?: string[], tx?: Transaction) => Promise<EntryBase[]>;
|
|
18
|
+
load(tableName: string, attributes: Record<string, string>, pk: Attribute<Natural, unknown>, model: new (from: "load") => EntryBase, table: Table): (where: string, order?: string | string[], limit?: number, tx?: Transaction) => Promise<EntryBase[]>;
|
|
19
19
|
remove(tableName: string, pk: Attribute<Natural, unknown>): (this: Record<string, Natural> & {
|
|
20
20
|
tx?: TransactionPG;
|
|
21
21
|
}) => Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Daniele Ricci <daniele.icc@gmail.com> (https://github.com/iccicci)",
|
|
3
|
-
"bugs": "https://github.com/iccicci/sedentary
|
|
3
|
+
"bugs": "https://github.com/iccicci/sedentary/issues",
|
|
4
4
|
"contributors": [
|
|
5
5
|
"Daniele Ricci <daniele.icc@gmail.com> (https://github.com/iccicci)",
|
|
6
6
|
"yossarian <sergiybiluk@gmail.com> (https://github.com/captain-yossarian)"
|
|
@@ -9,31 +9,16 @@
|
|
|
9
9
|
"@types/pg": "8.6.5",
|
|
10
10
|
"pg": "8.7.3",
|
|
11
11
|
"pg-format": "1.0.4",
|
|
12
|
-
"sedentary": "0.0.
|
|
12
|
+
"sedentary": "0.0.42"
|
|
13
13
|
},
|
|
14
14
|
"description": "The ORM which never needs to migrate - PostgreSQL",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@types/mocha": "9.1.1",
|
|
17
|
-
"@types/node": "18.0.0",
|
|
18
|
-
"@types/pg-format": "1.0.2",
|
|
19
|
-
"@types/yamljs": "0.2.31",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "5.30.0",
|
|
21
|
-
"@typescript-eslint/parser": "5.30.0",
|
|
22
|
-
"eslint": "8.18.0",
|
|
23
|
-
"mocha": "10.0.0",
|
|
24
|
-
"nyc": "15.1.0",
|
|
25
|
-
"prettier": "2.7.1",
|
|
26
|
-
"ts-node": "10.8.1",
|
|
27
|
-
"typescript": "4.7.4",
|
|
28
|
-
"yamljs": "0.3.0"
|
|
29
|
-
},
|
|
30
15
|
"engines": {
|
|
31
16
|
"node": ">=14.0"
|
|
32
17
|
},
|
|
33
18
|
"funding": {
|
|
34
19
|
"url": "https://blockchain.info/address/1Md9WFAHrXTb3yPBwQWmUfv2RmzrtbHioB"
|
|
35
20
|
},
|
|
36
|
-
"homepage": "https://github.com/iccicci/sedentary-pg#readme",
|
|
21
|
+
"homepage": "https://github.com/iccicci/sedentary/packages/sedentary-pg#readme",
|
|
37
22
|
"keywords": [
|
|
38
23
|
"DB",
|
|
39
24
|
"ORM",
|
|
@@ -47,42 +32,20 @@
|
|
|
47
32
|
"main": "./dist/cjs/index.js",
|
|
48
33
|
"module": "./dist/es/index.js",
|
|
49
34
|
"name": "sedentary-pg",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"endOfLine": "lf",
|
|
53
|
-
"jsxBracketSameLine": true,
|
|
54
|
-
"printWidth": 200,
|
|
55
|
-
"trailingComma": "none",
|
|
56
|
-
"useTabs": false
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"fsevents": "2.3.2"
|
|
57
37
|
},
|
|
58
38
|
"readmeFilename": "README.md",
|
|
59
|
-
"repository": "https://github.com/iccicci/sedentary
|
|
39
|
+
"repository": "https://github.com/iccicci/sedentary",
|
|
60
40
|
"scripts": {
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"version": "node -r ts-node/register utils.ts version"
|
|
69
|
-
},
|
|
70
|
-
"tsd": {
|
|
71
|
-
"compilerOptions": {
|
|
72
|
-
"alwaysStrict": true,
|
|
73
|
-
"esModuleInterop": true,
|
|
74
|
-
"moduleResolution": "Node",
|
|
75
|
-
"noImplicitAny": true,
|
|
76
|
-
"noImplicitReturns": true,
|
|
77
|
-
"noImplicitThis": true,
|
|
78
|
-
"strict": true,
|
|
79
|
-
"strictBindCallApply": true,
|
|
80
|
-
"strictFunctionTypes": true,
|
|
81
|
-
"strictNullChecks": true,
|
|
82
|
-
"strictPropertyInitialization": true,
|
|
83
|
-
"target": "ESNext"
|
|
84
|
-
}
|
|
41
|
+
"build": "make build",
|
|
42
|
+
"coverage": "jest --coverage --runInBand",
|
|
43
|
+
"deploy": "npm_config_registry=\"registry.npmjs.org\" npm publish",
|
|
44
|
+
"precoverage": "make pretest",
|
|
45
|
+
"preinstall": "if [ -f Makefile ] ; then make ; fi",
|
|
46
|
+
"pretest": "make pretest",
|
|
47
|
+
"test": "jest --runInBand"
|
|
85
48
|
},
|
|
86
49
|
"types": "./dist/types/index.d.ts",
|
|
87
|
-
"version": "0.0.
|
|
50
|
+
"version": "0.0.42"
|
|
88
51
|
}
|