sedentary-pg 0.0.53 → 0.1.0
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 +46 -24
- package/package.json +13 -19
- package/dist/cjs/adsrc.js +0 -9
- package/dist/cjs/index.js +0 -31
- package/dist/cjs/pgdb.js +0 -547
- package/dist/es/adsrc.js +0 -5
- package/dist/es/index.js +0 -24
- package/dist/es/pgdb.js +0 -541
- package/dist/types/adsrc.d.ts +0 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/pgdb.d.ts +0 -47
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# sedentary-pg
|
|
2
2
|
|
|
3
3
|
[![Build Status][travis-badge]][travis-url]
|
|
4
|
-
[![Code
|
|
5
|
-
[![Test Coverage][cover-badge]][
|
|
4
|
+
[![Code Quality][qlty-badge]][qlty-url]
|
|
5
|
+
[![Test Coverage][cover-badge]][qlty-url]
|
|
6
6
|
|
|
7
7
|
[![NPM version][npm-badge]][npm-url]
|
|
8
8
|
[![NPM downloads][npm-downloads-badge]][npm-url]
|
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
[![Dependents][deps-badge]][npm-url]
|
|
13
13
|
[![Donate][donate-badge]][donate-url]
|
|
14
14
|
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[deps-badge]: https://
|
|
19
|
-
[donate-badge]: https://
|
|
15
|
+
[cover-badge]: https://qlty.sh/gh/iccicci/projects/sedentary/coverage.svg
|
|
16
|
+
[qlty-badge]: https://qlty.sh/gh/iccicci/projects/sedentary/maintainability.svg
|
|
17
|
+
[qlty-url]: https://qlty.sh/gh/iccicci/projects/sedentary
|
|
18
|
+
[deps-badge]: https://img.shields.io/librariesio/dependents/npm/sedentary-pg?logo=npm
|
|
19
|
+
[donate-badge]: https://img.shields.io/static/v1?label=donate&message=bitcoin&color=blue&logo=bitcoin
|
|
20
20
|
[donate-url]: https://blockchain.info/address/1Md9WFAHrXTb3yPBwQWmUfv2RmzrtbHioB
|
|
21
21
|
[github-url]: https://github.com/iccicci/sedentary-pg
|
|
22
|
-
[npm-downloads-badge]: https://
|
|
23
|
-
[npm-badge]: https://
|
|
22
|
+
[npm-downloads-badge]: https://img.shields.io/npm/dw/sedentary-pg?logo=npm
|
|
23
|
+
[npm-badge]: https://img.shields.io/npm/v/sedentary-pg?color=green&logo=npm
|
|
24
24
|
[npm-url]: https://www.npmjs.com/package/sedentary-pg
|
|
25
|
-
[stars-badge]: https://
|
|
26
|
-
[travis-badge]: https://
|
|
27
|
-
[travis-url]: https://app.travis-ci.com/github/iccicci/sedentary
|
|
28
|
-
[types-badge]: https://
|
|
25
|
+
[stars-badge]: https://img.shields.io/github/stars/iccicci/sedentary-pg?logo=github&style=flat&color=green
|
|
26
|
+
[travis-badge]: https://img.shields.io/travis/com/iccicci/sedentary?logo=travis
|
|
27
|
+
[travis-url]: https://app.travis-ci.com/github/iccicci/sedentary
|
|
28
|
+
[types-badge]: https://img.shields.io/static/v1?label=types&message=included&color=green&logo=typescript
|
|
29
29
|
|
|
30
30
|
# under development
|
|
31
31
|
|
|
@@ -33,22 +33,24 @@
|
|
|
33
33
|
|
|
34
34
|
The **PostgreSQL** specialized package of [Sedentary](https://www.npmjs.com/package/sedentary).
|
|
35
35
|
|
|
36
|
+
Other DB engines: MySQL and SQLite are in todo but not yet planned.
|
|
37
|
+
|
|
36
38
|
# Usage
|
|
37
39
|
|
|
38
40
|
```javascript
|
|
39
41
|
import { SedentaryPG } from "sedentary-pg";
|
|
40
42
|
|
|
41
|
-
const db = new SedentaryPG(
|
|
43
|
+
const db = new SedentaryPG({ database: "db", user: "user", password: "pass" });
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
num: db.
|
|
45
|
-
str: db.VarChar(30)
|
|
45
|
+
const Items = db.model("Item", {
|
|
46
|
+
num: db.Int(),
|
|
47
|
+
str: db.VarChar({ size: 30 })
|
|
46
48
|
});
|
|
47
49
|
|
|
48
50
|
(async function () {
|
|
49
51
|
await db.connect();
|
|
50
52
|
|
|
51
|
-
const item = Items
|
|
53
|
+
const item = new Items();
|
|
52
54
|
|
|
53
55
|
item.num = 0;
|
|
54
56
|
item.str = "0";
|
|
@@ -61,6 +63,22 @@ class Items extends db.model("Item", {
|
|
|
61
63
|
})();
|
|
62
64
|
```
|
|
63
65
|
|
|
66
|
+
With TypeScript the instance can be typed using `Entry<typeof Model>`:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { Entry, SedentaryPG } from "sedentary-pg";
|
|
70
|
+
|
|
71
|
+
const db = new SedentaryPG({ database: "db", user: "user", password: "pass" });
|
|
72
|
+
|
|
73
|
+
const Items = db.model("Item", { num: db.Int(), str: db.VarChar({ size: 30 }) });
|
|
74
|
+
type Item = Entry<typeof Items>;
|
|
75
|
+
|
|
76
|
+
const item: Item = new Items();
|
|
77
|
+
|
|
78
|
+
item.num = 0;
|
|
79
|
+
item.str = "0";
|
|
80
|
+
```
|
|
81
|
+
|
|
64
82
|
# Installation
|
|
65
83
|
|
|
66
84
|
With [npm](https://www.npmjs.com/package/sedentary-pg):
|
|
@@ -77,15 +95,16 @@ The full documentation is on [sedentary.readthedocs.io](https://sedentary.readth
|
|
|
77
95
|
|
|
78
96
|
Requires:
|
|
79
97
|
|
|
80
|
-
- Node.js: **
|
|
81
|
-
- TypeScript: **
|
|
98
|
+
- Node.js: **v20**
|
|
99
|
+
- TypeScript: **v5.7** (or none if used in a JavaScript project).
|
|
100
|
+
- PostgreSQL: **v15**
|
|
82
101
|
|
|
83
|
-
The package is tested under [all version combinations](https://app.travis-ci.com/github/iccicci/sedentary
|
|
102
|
+
The package is tested under [all version combinations](https://app.travis-ci.com/github/iccicci/sedentary)
|
|
84
103
|
of **Node.js** currently supported accordingly to [Node.js Release](https://github.com/nodejs/Release#readme) and of
|
|
85
104
|
**PostgreSQL** currently supported accordingly to
|
|
86
105
|
[PostgreSQL Versioning](https://www.postgresql.org/support/versioning/).
|
|
87
106
|
|
|
88
|
-
To work with the package under Windows,
|
|
107
|
+
To work with the package under Windows, `bash.exe` can be configured as the _script-shell_.
|
|
89
108
|
|
|
90
109
|
```
|
|
91
110
|
> npm config set script-shell bash.exe
|
|
@@ -97,9 +116,12 @@ To work with the package under Windows, be sure to configure `bash.exe` as your
|
|
|
97
116
|
|
|
98
117
|
# Bugs
|
|
99
118
|
|
|
100
|
-
|
|
119
|
+
Bugs and inconsistencies can be reported [@github](https://github.com/iccicci/sedentary-pg/issues).
|
|
101
120
|
|
|
102
121
|
# Donating
|
|
103
122
|
|
|
104
|
-
|
|
123
|
+
Satoshis can be donated to this bitcoin address if the package is found useful:
|
|
124
|
+
|
|
125
|
+
<!-- cSpell: disable -->
|
|
126
|
+
|
|
105
127
|
**1Md9WFAHrXTb3yPBwQWmUfv2RmzrtbHioB**
|
package/package.json
CHANGED
|
@@ -6,46 +6,40 @@
|
|
|
6
6
|
"yossarian <sergiybiluk@gmail.com> (https://github.com/captain-yossarian)"
|
|
7
7
|
],
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@types/pg": "8.
|
|
10
|
-
"pg": "8.
|
|
11
|
-
"pg-format": "1.0.4",
|
|
12
|
-
"sedentary": "0.0
|
|
9
|
+
"@types/pg": "^8.16.0",
|
|
10
|
+
"pg": "^8.18.0",
|
|
11
|
+
"pg-format": "^1.0.4",
|
|
12
|
+
"sedentary": "0.1.0"
|
|
13
13
|
},
|
|
14
14
|
"description": "The ORM which never needs to migrate - PostgreSQL",
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=20.19"
|
|
17
17
|
},
|
|
18
18
|
"funding": {
|
|
19
19
|
"url": "https://blockchain.info/address/1Md9WFAHrXTb3yPBwQWmUfv2RmzrtbHioB"
|
|
20
20
|
},
|
|
21
|
-
"homepage": "https://github.com/iccicci/sedentary/packages/sedentary-pg#readme",
|
|
21
|
+
"homepage": "https://github.com/iccicci/sedentary/tree/master/packages/sedentary-pg#readme",
|
|
22
22
|
"keywords": [
|
|
23
23
|
"DB",
|
|
24
24
|
"ORM",
|
|
25
25
|
"database",
|
|
26
26
|
"migration",
|
|
27
|
-
"
|
|
28
|
-
"postgresql",
|
|
29
|
-
"sqlite"
|
|
27
|
+
"postgresql"
|
|
30
28
|
],
|
|
31
29
|
"license": "MIT",
|
|
32
30
|
"main": "./dist/cjs/index.js",
|
|
33
31
|
"module": "./dist/es/index.js",
|
|
34
32
|
"name": "sedentary-pg",
|
|
35
|
-
"optionalDependencies": {
|
|
36
|
-
"fsevents": "2.3.2"
|
|
37
|
-
},
|
|
38
33
|
"readmeFilename": "README.md",
|
|
39
|
-
"repository":
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/iccicci/sedentary.git"
|
|
37
|
+
},
|
|
40
38
|
"scripts": {
|
|
41
39
|
"build": "make build",
|
|
42
|
-
"coverage": "jest --coverage --no-cache --runInBand",
|
|
43
40
|
"deploy": "make deploy",
|
|
44
|
-
"
|
|
45
|
-
"preinstall": "if [ -f Makefile ] ; then make ; fi",
|
|
46
|
-
"pretest": "make pretest",
|
|
47
|
-
"test": "jest --no-cache --runInBand"
|
|
41
|
+
"preinstall": "if [ -f Makefile ] ; then make ; fi"
|
|
48
42
|
},
|
|
49
43
|
"types": "./dist/types/index.d.ts",
|
|
50
|
-
"version": "0.0
|
|
44
|
+
"version": "0.1.0"
|
|
51
45
|
}
|
package/dist/cjs/adsrc.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.adsrc = void 0;
|
|
4
|
-
// cspell: disable-next-line
|
|
5
|
-
function adsrc(version) {
|
|
6
|
-
// cspell: disable-next-line
|
|
7
|
-
return version >= 12 ? "pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid) AS adsrc" : "adsrc";
|
|
8
|
-
}
|
|
9
|
-
exports.adsrc = adsrc;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SedentaryPG = exports.Type = exports.EntryBase = exports.TransactionPG = void 0;
|
|
4
|
-
const sedentary_1 = require("sedentary");
|
|
5
|
-
const pgdb_1 = require("./pgdb");
|
|
6
|
-
var pgdb_2 = require("./pgdb");
|
|
7
|
-
Object.defineProperty(exports, "TransactionPG", { enumerable: true, get: function () { return pgdb_2.TransactionPG; } });
|
|
8
|
-
var sedentary_2 = require("sedentary");
|
|
9
|
-
Object.defineProperty(exports, "EntryBase", { enumerable: true, get: function () { return sedentary_2.EntryBase; } });
|
|
10
|
-
Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return sedentary_2.Type; } });
|
|
11
|
-
class SedentaryPG extends sedentary_1.Sedentary {
|
|
12
|
-
constructor(connection, options) {
|
|
13
|
-
super(options);
|
|
14
|
-
if (!(connection instanceof Object))
|
|
15
|
-
throw new Error("SedentaryPG.constructor: 'connection' argument: Wrong type, expected 'Object'");
|
|
16
|
-
this.db = new pgdb_1.PGDB(connection, this.log);
|
|
17
|
-
}
|
|
18
|
-
FKey(attribute, options) {
|
|
19
|
-
const { attributeName, modelName, unique } = attribute;
|
|
20
|
-
if (!unique)
|
|
21
|
-
throw new Error(`SedentaryPG.FKey: '${modelName}' model: '${attributeName}' attribute: is not unique: can't be used as FKey target`);
|
|
22
|
-
return super.FKey(attribute, options);
|
|
23
|
-
}
|
|
24
|
-
begin() {
|
|
25
|
-
return this.db.begin();
|
|
26
|
-
}
|
|
27
|
-
client() {
|
|
28
|
-
return this.db.client();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.SedentaryPG = SedentaryPG;
|