w-orm-postgresql 1.0.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.
Files changed (51) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +324 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +15 -0
  9. package/dist/w-orm-postgresql.umd.js +7 -0
  10. package/dist/w-orm-postgresql.umd.js.map +1 -0
  11. package/docs/WOrmPostgresql.html +1655 -0
  12. package/docs/WOrmPostgresql.mjs.html +952 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  31. package/docs/index.html +84 -0
  32. package/docs/scripts/collapse.js +39 -0
  33. package/docs/scripts/commonNav.js +28 -0
  34. package/docs/scripts/linenumber.js +25 -0
  35. package/docs/scripts/nav.js +12 -0
  36. package/docs/scripts/polyfill.js +4 -0
  37. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  38. package/docs/scripts/prettify/lang-css.js +2 -0
  39. package/docs/scripts/prettify/prettify.js +28 -0
  40. package/docs/scripts/search.js +99 -0
  41. package/docs/styles/jsdoc.css +776 -0
  42. package/docs/styles/prettify.css +80 -0
  43. package/g-basic.mjs +306 -0
  44. package/package.json +32 -0
  45. package/script.txt +18 -0
  46. package/src/WOrmPostgresql.mjs +880 -0
  47. package/test/basic.test.mjs +429 -0
  48. package/toolg/addVersion.mjs +4 -0
  49. package/toolg/cleanFolder.mjs +4 -0
  50. package/toolg/gDistRollup.mjs +25 -0
  51. package/toolg/modifyReadme.mjs +4 -0
@@ -0,0 +1,80 @@
1
+ .pln {
2
+ color: #ddd;
3
+ }
4
+
5
+ /* string content */
6
+ .str {
7
+ color: #61ce3c;
8
+ }
9
+
10
+ /* a keyword */
11
+ .kwd {
12
+ color: #fbde2d;
13
+ }
14
+
15
+ /* a comment */
16
+ .com {
17
+ color: #aeaeae;
18
+ }
19
+
20
+ /* a type name */
21
+ .typ {
22
+ color: #8da6ce;
23
+ }
24
+
25
+ /* a literal value */
26
+ .lit {
27
+ color: #fbde2d;
28
+ }
29
+
30
+ /* punctuation */
31
+ .pun {
32
+ color: #ddd;
33
+ }
34
+
35
+ /* lisp open bracket */
36
+ .opn {
37
+ color: #000000;
38
+ }
39
+
40
+ /* lisp close bracket */
41
+ .clo {
42
+ color: #000000;
43
+ }
44
+
45
+ /* a markup tag name */
46
+ .tag {
47
+ color: #8da6ce;
48
+ }
49
+
50
+ /* a markup attribute name */
51
+ .atn {
52
+ color: #fbde2d;
53
+ }
54
+
55
+ /* a markup attribute value */
56
+ .atv {
57
+ color: #ddd;
58
+ }
59
+
60
+ /* a declaration */
61
+ .dec {
62
+ color: #EF5050;
63
+ }
64
+
65
+ /* a variable name */
66
+ .var {
67
+ color: #c82829;
68
+ }
69
+
70
+ /* a function name */
71
+ .fun {
72
+ color: #4271ae;
73
+ }
74
+
75
+ /* Specify class=linenums on a pre to get line numbering */
76
+ ol.linenums {
77
+ margin-top: 0;
78
+ margin-bottom: 0;
79
+ padding-bottom: 2px;
80
+ }
package/g-basic.mjs ADDED
@@ -0,0 +1,306 @@
1
+ import wo from './src/WOrmPostgresql.mjs'
2
+ //import wo from './dist/w-orm-postgresql.umd.js'
3
+
4
+
5
+ let opt = {
6
+ url: 'postgresql://username:password@127.0.0.1:5432',
7
+ db: 'worm',
8
+ cl: 'users',
9
+ }
10
+
11
+ let rs = [
12
+ {
13
+ time: '2025-01-01T00:00:00Z',
14
+ name: 'peter',
15
+ value: 123,
16
+ },
17
+ {
18
+ time: '2025-01-01T00:01:00Z',
19
+ name: 'rosemary',
20
+ value: 123.456,
21
+ },
22
+ {
23
+ time: '2025-01-01T00:02:00Z',
24
+ name: 'kettle',
25
+ value: 456,
26
+ },
27
+ {
28
+ time: '2025-01-01T00:03:00Z',
29
+ name: 'peter',
30
+ value: 200,
31
+ },
32
+ {
33
+ time: '2025-01-01T00:04:00Z',
34
+ name: 'rosemary',
35
+ value: 123.1236,
36
+ },
37
+ {
38
+ time: '2025-01-01T00:05:00Z',
39
+ name: 'kettle',
40
+ value: 488,
41
+ },
42
+ {
43
+ time: '2025-01-01T00:06:00Z',
44
+ name: 'peter',
45
+ value: 125,
46
+ },
47
+ {
48
+ time: '2025-01-01T00:07:00Z',
49
+ name: 'rosemary',
50
+ value: 124.76,
51
+ },
52
+ {
53
+ time: '2025-01-01T00:08:00Z',
54
+ name: 'kettle',
55
+ value: 524,
56
+ },
57
+ {
58
+ time: '2025-01-01T00:09:00Z',
59
+ name: 'peter',
60
+ value: 127,
61
+ },
62
+ {
63
+ time: '2025-01-01T00:10:00Z',
64
+ name: 'rosemary',
65
+ value: 113.98,
66
+ },
67
+ {
68
+ time: '2025-01-01T00:11:00Z',
69
+ name: 'kettle',
70
+ value: 447,
71
+ },
72
+ {
73
+ time: '2025-01-01T00:12:00Z',
74
+ name: 'peter',
75
+ value: 131,
76
+ },
77
+ ]
78
+
79
+ let rsm = [
80
+ { //相同
81
+ time: '2025-01-01T00:09:00Z',
82
+ name: 'peter',
83
+ value: 127,
84
+ },
85
+ { //name變更
86
+ time: '2025-01-01T00:10:00Z',
87
+ name: 'rosemary(modify)',
88
+ value: 113.98,
89
+ },
90
+ { //name變更
91
+ time: '2025-01-01T00:11:00Z',
92
+ name: 'kettle(modify)',
93
+ value: 447,
94
+ },
95
+ { //無name且value變更
96
+ time: '2025-01-01T00:12:00Z',
97
+ // name: 'peter',
98
+ value: 99,
99
+ },
100
+ { //無time須新增且新增數據無value
101
+ time: '2025-01-01T00:13:00Z',
102
+ name: 'sandler',
103
+ },
104
+ ]
105
+
106
+ async function test() {
107
+
108
+ //w
109
+ let w = wo(opt)
110
+ // console.log('w', w)
111
+
112
+ await w.createTable(opt.cl, 'time', {
113
+ time: '2000-01-01T00:00:00Z', //time
114
+ name: 'abc', //string
115
+ value: 0.1, //float
116
+ })
117
+ .then(function(msg) {
118
+ // console.log('createTable then', msg)
119
+ })
120
+ .catch(function(msg) {
121
+ // console.log('createTable catch', msg)
122
+ })
123
+
124
+ //on
125
+ w.on('change', function(mode, data, res) {
126
+ console.log('change', mode)
127
+ })
128
+
129
+ //delAll
130
+ await w.delAll()
131
+ .then(function(msg) {
132
+ console.log('delAll then', msg)
133
+ })
134
+ .catch(function(msg) {
135
+ console.log('delAll catch', msg)
136
+ })
137
+
138
+ //insert
139
+ await w.insert(rs)
140
+ .then(function(msg) {
141
+ console.log('insert then', msg)
142
+ })
143
+ .catch(function(msg) {
144
+ console.log('insert catch', msg)
145
+ })
146
+
147
+ //save
148
+ await w.save(rsm, { autoInsert: true })
149
+ .then(function(msg) {
150
+ console.log('save then', msg)
151
+ })
152
+ .catch(function(msg) {
153
+ console.log('save catch', msg)
154
+ })
155
+
156
+ //select all
157
+ let ss = await w.select()
158
+ console.log('select all', ss)
159
+
160
+ //select
161
+ let so = await w.select({ name: 'rosemary' })
162
+ console.log('select by name', so)
163
+
164
+ //select by $and, $gt, $lt
165
+ let spa = await w.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
166
+ console.log('select by $and, $gt, $lt', spa)
167
+
168
+ //select by $or, $gte, $lte
169
+ let spb = await w.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
170
+ console.log('select by $or, $gte, $lte', spb)
171
+
172
+ //select by $or, $and, $ne, $in, $nin
173
+ let spc = await w.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
174
+ console.log('select by $or, $and, $ne, $in, $nin', spc)
175
+
176
+ // //select by regex
177
+ // let sr = await w.select({ name: { $regex: 'PeT', $options: '$i' } })
178
+ // console.log('selectReg', sr)
179
+
180
+ //del
181
+ let d = {
182
+ time: '2024-01-01T00:00:00Z',
183
+ }
184
+ await w.del(d)
185
+ .then(function(msg) {
186
+ console.log('del then', msg)
187
+ })
188
+ .catch(function(msg) {
189
+ console.log('del catch', msg)
190
+ })
191
+
192
+ //del
193
+ let ds = ss.filter(function(v) {
194
+ return v.name.indexOf('peter') >= 0 || v.name.indexOf('kettle') >= 0 || v.name.indexOf('sandler') >= 0
195
+ })
196
+ await w.del(ds)
197
+ .then(function(msg) {
198
+ console.log('del then', msg)
199
+ })
200
+ .catch(function(msg) {
201
+ console.log('del catch', msg)
202
+ })
203
+
204
+ //select all final
205
+ let ss2 = await w.select()
206
+ console.log('select all final', ss2)
207
+
208
+ }
209
+ test()
210
+ // change delAll
211
+ // delAll then { n: 5, nDeleted: 5, ok: 1 }
212
+ // change insert
213
+ // insert then { n: 13, nInserted: 13, ok: 1 }
214
+ // change save
215
+ // save then [
216
+ // { n: 1, nModified: 0, ok: 1 },
217
+ // { n: 1, nModified: 1, ok: 1 },
218
+ // { n: 1, nModified: 1, ok: 1 },
219
+ // { n: 1, nModified: 1, ok: 1 },
220
+ // { n: 1, nInserted: 1, ok: 1 }
221
+ // ]
222
+ // select all [
223
+ // { time: 2025-01-01T00:00:00.000Z, name: 'peter', value: 123 },
224
+ // { time: 2025-01-01T00:01:00.000Z, name: 'rosemary', value: 123.456 },
225
+ // { time: 2025-01-01T00:02:00.000Z, name: 'kettle', value: 456 },
226
+ // { time: 2025-01-01T00:03:00.000Z, name: 'peter', value: 200 },
227
+ // { time: 2025-01-01T00:04:00.000Z, name: 'rosemary', value: 123.1236 },
228
+ // { time: 2025-01-01T00:05:00.000Z, name: 'kettle', value: 488 },
229
+ // { time: 2025-01-01T00:06:00.000Z, name: 'peter', value: 125 },
230
+ // { time: 2025-01-01T00:07:00.000Z, name: 'rosemary', value: 124.76 },
231
+ // { time: 2025-01-01T00:08:00.000Z, name: 'kettle', value: 524 },
232
+ // { time: 2025-01-01T00:09:00.000Z, name: 'peter', value: 127 },
233
+ // {
234
+ // time: 2025-01-01T00:10:00.000Z,
235
+ // name: 'rosemary(modify)',
236
+ // value: 113.98
237
+ // },
238
+ // {
239
+ // time: 2025-01-01T00:11:00.000Z,
240
+ // name: 'kettle(modify)',
241
+ // value: 447
242
+ // },
243
+ // { time: 2025-01-01T00:12:00.000Z, name: 'peter', value: 99 },
244
+ // { time: 2025-01-01T00:13:00.000Z, name: 'sandler', value: null }
245
+ // ]
246
+ // select by name [
247
+ // { time: 2025-01-01T00:01:00.000Z, name: 'rosemary', value: 123.456 },
248
+ // { time: 2025-01-01T00:04:00.000Z, name: 'rosemary', value: 123.1236 },
249
+ // { time: 2025-01-01T00:07:00.000Z, name: 'rosemary', value: 124.76 }
250
+ // ]
251
+ // select by $and, $gt, $lt [
252
+ // { time: 2025-01-01T00:01:00.000Z, name: 'rosemary', value: 123.456 },
253
+ // { time: 2025-01-01T00:04:00.000Z, name: 'rosemary', value: 123.1236 },
254
+ // { time: 2025-01-01T00:06:00.000Z, name: 'peter', value: 125 },
255
+ // { time: 2025-01-01T00:07:00.000Z, name: 'rosemary', value: 124.76 },
256
+ // { time: 2025-01-01T00:09:00.000Z, name: 'peter', value: 127 }
257
+ // ]
258
+ // select by $or, $gte, $lte [
259
+ // { time: 2025-01-01T00:02:00.000Z, name: 'kettle', value: 456 },
260
+ // { time: 2025-01-01T00:03:00.000Z, name: 'peter', value: 200 },
261
+ // { time: 2025-01-01T00:05:00.000Z, name: 'kettle', value: 488 },
262
+ // { time: 2025-01-01T00:08:00.000Z, name: 'kettle', value: 524 },
263
+ // {
264
+ // time: 2025-01-01T00:11:00.000Z,
265
+ // name: 'kettle(modify)',
266
+ // value: 447
267
+ // }
268
+ // ]
269
+ // select by $or, $and, $ne, $in, $nin [
270
+ // { time: 2025-01-01T00:01:00.000Z, name: 'rosemary', value: 123.456 },
271
+ // { time: 2025-01-01T00:02:00.000Z, name: 'kettle', value: 456 },
272
+ // { time: 2025-01-01T00:05:00.000Z, name: 'kettle', value: 488 },
273
+ // { time: 2025-01-01T00:08:00.000Z, name: 'kettle', value: 524 },
274
+ // {
275
+ // time: 2025-01-01T00:11:00.000Z,
276
+ // name: 'kettle(modify)',
277
+ // value: 447
278
+ // }
279
+ // ]
280
+ // change del
281
+ // del then [ { n: 1, nDeleted: 0, ok: 1 } ]
282
+ // change del
283
+ // del then [
284
+ // { n: 1, nDeleted: 1, ok: 1 },
285
+ // { n: 1, nDeleted: 1, ok: 1 },
286
+ // { n: 1, nDeleted: 1, ok: 1 },
287
+ // { n: 1, nDeleted: 1, ok: 1 },
288
+ // { n: 1, nDeleted: 1, ok: 1 },
289
+ // { n: 1, nDeleted: 1, ok: 1 },
290
+ // { n: 1, nDeleted: 1, ok: 1 },
291
+ // { n: 1, nDeleted: 1, ok: 1 },
292
+ // { n: 1, nDeleted: 1, ok: 1 },
293
+ // { n: 1, nDeleted: 1, ok: 1 }
294
+ // ]
295
+ // select all final [
296
+ // { time: 2025-01-01T00:01:00.000Z, name: 'rosemary', value: 123.456 },
297
+ // { time: 2025-01-01T00:04:00.000Z, name: 'rosemary', value: 123.1236 },
298
+ // { time: 2025-01-01T00:07:00.000Z, name: 'rosemary', value: 124.76 },
299
+ // {
300
+ // time: 2025-01-01T00:10:00.000Z,
301
+ // name: 'rosemary(modify)',
302
+ // value: 113.98
303
+ // }
304
+ // ]
305
+
306
+ //node --experimental-modules g-basic.mjs
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "w-orm-postgresql",
3
+ "version": "1.0.0",
4
+ "main": "dist/w-orm-postgresql.umd.js",
5
+ "dependencies": {
6
+ "mongo-sql": "^6.2.0",
7
+ "pg": "^8.14.1",
8
+ "lodash-es": "^4.17.21",
9
+ "wsemi": "^1.7.72"
10
+ },
11
+ "devDependencies": {
12
+ "w-package-tools": "^1.0.82"
13
+ },
14
+ "scripts": {
15
+ "test": "mocha --parallel --timeout 60000 --experimental-modules",
16
+ "deploy": "gh-pages -d docs"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/yuda-lyu/w-orm-postgresql.git"
21
+ },
22
+ "keywords": [
23
+ "package",
24
+ "tool",
25
+ "operator",
26
+ "postgresql",
27
+ "ORM",
28
+ "nodejs"
29
+ ],
30
+ "author": "yuda-lyu(semisphere)",
31
+ "license": "MIT"
32
+ }
package/script.txt ADDED
@@ -0,0 +1,18 @@
1
+ #node --experimental-modules toolg/addVersion.mjs
2
+ node --experimental-modules toolg/modifyReadme.mjs
3
+
4
+ node --experimental-modules toolg/cleanFolder.mjs
5
+ ./node_modules/.bin/jsdoc -c .jsdoc
6
+
7
+ node --experimental-modules toolg/gDistRollup.mjs
8
+
9
+ git add . -A
10
+ git commit -m 'modify: '
11
+ git push origin master:master
12
+
13
+ npm run deploy
14
+
15
+ #npm test
16
+
17
+ #npm publish
18
+