w-orm-reladb 1.0.42 → 1.0.44
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/.github/workflows/ci-test.yml +3 -3
- package/.github/workflows/ci.yml +52 -0
- package/README.md +5 -6
- package/babel.config.js +4 -3
- package/dist/w-orm-reladb.umd.js +2 -2
- package/dist/w-orm-reladb.umd.js.map +1 -1
- package/docs/WOrmReladb.html +13 -13
- package/docs/WOrmReladb.mjs.html +28 -7
- package/docs/index.html +1 -1
- package/g-genModelsByTabs.mjs +4 -1
- package/g-mssql-concurrency.mjs +4 -1
- package/g-mssql-timerQuery.mjs +4 -1
- package/g-mssql-transaction-commit.mjs +4 -1
- package/g-mssql-transaction-rollback.mjs +4 -1
- package/g-mssql.mjs +4 -1
- package/g-sqlite-concurrency.mjs +4 -1
- package/g-sqlite-encryption-transaction-commit.mjs +5 -2
- package/g-sqlite-encryption-transaction-rollback.mjs +1 -1
- package/g-sqlite-encryption.mjs +5 -2
- package/g-sqlite-transaction-commit.mjs +5 -2
- package/g-sqlite-transaction-rollback.mjs +5 -2
- package/g-sqlite.mjs +5 -2
- package/package.json +8 -8
- package/script.txt +4 -4
- package/src/WOrmReladb.mjs +27 -6
- package/test/api-fixtures.mjs +48 -0
- package/test/api-mssql.test.mjs +212 -0
- package/test/api-sqlite.test.mjs +236 -0
- package/worm.sqlite +0 -0
- package/test/all.test.mjs +0 -10
package/docs/WOrmReladb.html
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
|
|
82
82
|
<dt class="tag-source">Source:</dt>
|
|
83
83
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
84
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
84
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line51">line 51</a>
|
|
85
85
|
</li></ul></dd>
|
|
86
86
|
|
|
87
87
|
|
|
@@ -750,7 +750,7 @@
|
|
|
750
750
|
|
|
751
751
|
<dt class="tag-source">Source:</dt>
|
|
752
752
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
753
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
753
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line236">line 236</a>
|
|
754
754
|
</li></ul></dd>
|
|
755
755
|
|
|
756
756
|
|
|
@@ -858,7 +858,7 @@
|
|
|
858
858
|
|
|
859
859
|
<dt class="tag-source">Source:</dt>
|
|
860
860
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
861
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
861
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line936">line 936</a>
|
|
862
862
|
</li></ul></dd>
|
|
863
863
|
|
|
864
864
|
|
|
@@ -966,7 +966,7 @@
|
|
|
966
966
|
|
|
967
967
|
<dt class="tag-source">Source:</dt>
|
|
968
968
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
969
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
969
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line711">line 711</a>
|
|
970
970
|
</li></ul></dd>
|
|
971
971
|
|
|
972
972
|
|
|
@@ -1293,7 +1293,7 @@
|
|
|
1293
1293
|
|
|
1294
1294
|
<dt class="tag-source">Source:</dt>
|
|
1295
1295
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1296
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
1296
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line858">line 858</a>
|
|
1297
1297
|
</li></ul></dd>
|
|
1298
1298
|
|
|
1299
1299
|
|
|
@@ -1623,7 +1623,7 @@
|
|
|
1623
1623
|
|
|
1624
1624
|
<dt class="tag-source">Source:</dt>
|
|
1625
1625
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1626
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
1626
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line978">line 978</a>
|
|
1627
1627
|
</li></ul></dd>
|
|
1628
1628
|
|
|
1629
1629
|
|
|
@@ -2151,7 +2151,7 @@
|
|
|
2151
2151
|
|
|
2152
2152
|
<dt class="tag-source">Source:</dt>
|
|
2153
2153
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2154
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2154
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1026">line 1026</a>
|
|
2155
2155
|
</li></ul></dd>
|
|
2156
2156
|
|
|
2157
2157
|
|
|
@@ -2456,7 +2456,7 @@
|
|
|
2456
2456
|
|
|
2457
2457
|
<dt class="tag-source">Source:</dt>
|
|
2458
2458
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2459
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2459
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line252">line 252</a>
|
|
2460
2460
|
</li></ul></dd>
|
|
2461
2461
|
|
|
2462
2462
|
|
|
@@ -2564,7 +2564,7 @@
|
|
|
2564
2564
|
|
|
2565
2565
|
<dt class="tag-source">Source:</dt>
|
|
2566
2566
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2567
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2567
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line169">line 169</a>
|
|
2568
2568
|
</li></ul></dd>
|
|
2569
2569
|
|
|
2570
2570
|
|
|
@@ -2742,7 +2742,7 @@
|
|
|
2742
2742
|
|
|
2743
2743
|
<dt class="tag-source">Source:</dt>
|
|
2744
2744
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2745
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2745
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line406">line 406</a>
|
|
2746
2746
|
</li></ul></dd>
|
|
2747
2747
|
|
|
2748
2748
|
|
|
@@ -3069,7 +3069,7 @@
|
|
|
3069
3069
|
|
|
3070
3070
|
<dt class="tag-source">Source:</dt>
|
|
3071
3071
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3072
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
3072
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line511">line 511</a>
|
|
3073
3073
|
</li></ul></dd>
|
|
3074
3074
|
|
|
3075
3075
|
|
|
@@ -3436,7 +3436,7 @@
|
|
|
3436
3436
|
|
|
3437
3437
|
<dt class="tag-source">Source:</dt>
|
|
3438
3438
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3439
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
3439
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line277">line 277</a>
|
|
3440
3440
|
</li></ul></dd>
|
|
3441
3441
|
|
|
3442
3442
|
|
|
@@ -3763,7 +3763,7 @@
|
|
|
3763
3763
|
<br class="clear">
|
|
3764
3764
|
|
|
3765
3765
|
<footer>
|
|
3766
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.
|
|
3766
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Jul 23 2026 10:27:23 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
3767
3767
|
</footer>
|
|
3768
3768
|
|
|
3769
3769
|
<script>prettyPrint();</script>
|
package/docs/WOrmReladb.mjs.html
CHANGED
|
@@ -48,16 +48,18 @@
|
|
|
48
48
|
<pre class="prettyprint source linenums"><code>import path from 'path'
|
|
49
49
|
import events from 'events'
|
|
50
50
|
import Sequelize from 'sequelize'
|
|
51
|
-
import cloneDeep from 'lodash-es/cloneDeep.js'
|
|
52
|
-
import get from 'lodash-es/get.js'
|
|
53
|
-
import map from 'lodash-es/map.js'
|
|
54
|
-
import each from 'lodash-es/each.js'
|
|
55
|
-
import size from 'lodash-es/size.js'
|
|
56
|
-
import split from 'lodash-es/split.js'
|
|
51
|
+
import cloneDeep from 'lodash-es/cloneDeep.js'
|
|
52
|
+
import get from 'lodash-es/get.js'
|
|
53
|
+
import map from 'lodash-es/map.js'
|
|
54
|
+
import each from 'lodash-es/each.js'
|
|
55
|
+
import size from 'lodash-es/size.js'
|
|
56
|
+
import split from 'lodash-es/split.js'
|
|
57
57
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
58
58
|
import genID from 'wsemi/src/genID.mjs'
|
|
59
59
|
import isarr from 'wsemi/src/isarr.mjs'
|
|
60
|
+
import isearr from 'wsemi/src/isearr.mjs'
|
|
60
61
|
import isobj from 'wsemi/src/isobj.mjs'
|
|
62
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
61
63
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
62
64
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
63
65
|
import arrHas from 'wsemi/src/arrHas.mjs'
|
|
@@ -450,6 +452,15 @@ function WOrmReladb(opt = {}) {
|
|
|
450
452
|
*/
|
|
451
453
|
async function insert(data, option = {}) {
|
|
452
454
|
|
|
455
|
+
//check
|
|
456
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
457
|
+
return {
|
|
458
|
+
n: 0,
|
|
459
|
+
nInserted: 0,
|
|
460
|
+
ok: 1,
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
453
464
|
//instance
|
|
454
465
|
let instance = get(option, 'instance', null)
|
|
455
466
|
|
|
@@ -546,6 +557,11 @@ function WOrmReladb(opt = {}) {
|
|
|
546
557
|
*/
|
|
547
558
|
async function save(data, option = {}) {
|
|
548
559
|
|
|
560
|
+
//check
|
|
561
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
562
|
+
return []
|
|
563
|
+
}
|
|
564
|
+
|
|
549
565
|
//cloneDeep
|
|
550
566
|
data = cloneDeep(data)
|
|
551
567
|
|
|
@@ -741,6 +757,11 @@ function WOrmReladb(opt = {}) {
|
|
|
741
757
|
*/
|
|
742
758
|
async function del(data, option = {}) {
|
|
743
759
|
|
|
760
|
+
//check
|
|
761
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
762
|
+
return []
|
|
763
|
+
}
|
|
764
|
+
|
|
744
765
|
//cloneDeep
|
|
745
766
|
data = cloneDeep(data)
|
|
746
767
|
|
|
@@ -1111,7 +1132,7 @@ export default WOrmReladb
|
|
|
1111
1132
|
<br class="clear">
|
|
1112
1133
|
|
|
1113
1134
|
<footer>
|
|
1114
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.
|
|
1135
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Jul 23 2026 10:27:23 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1115
1136
|
</footer>
|
|
1116
1137
|
|
|
1117
1138
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
<br class="clear">
|
|
72
72
|
|
|
73
73
|
<footer>
|
|
74
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu Jul 23 2026 10:27:23 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
75
75
|
</footer>
|
|
76
76
|
|
|
77
77
|
<script>prettyPrint();</script>
|
package/g-genModelsByTabs.mjs
CHANGED
|
@@ -63,6 +63,9 @@ async function test() {
|
|
|
63
63
|
|
|
64
64
|
}
|
|
65
65
|
test()
|
|
66
|
+
.catch((err) => {
|
|
67
|
+
console.log(err)
|
|
68
|
+
})
|
|
66
69
|
// generate file: ./models/tb1.js
|
|
67
70
|
// generate file: ./models/tb2.js
|
|
68
71
|
// generate file: ./models/tb3.js
|
|
@@ -70,4 +73,4 @@ test()
|
|
|
70
73
|
// generate file: ./models/tb2.json
|
|
71
74
|
// generate file: ./models/tb3.json
|
|
72
75
|
|
|
73
|
-
//node
|
|
76
|
+
//node g-genModelsByTabs.mjs
|
package/g-mssql-concurrency.mjs
CHANGED
|
@@ -96,6 +96,9 @@ async function test() {
|
|
|
96
96
|
|
|
97
97
|
}
|
|
98
98
|
test()
|
|
99
|
+
.catch((err) => {
|
|
100
|
+
console.log(err)
|
|
101
|
+
})
|
|
99
102
|
// createStorage
|
|
100
103
|
// call save 1
|
|
101
104
|
// call select 2
|
|
@@ -106,4 +109,4 @@ test()
|
|
|
106
109
|
// save then 3 msg= [ { n: 1, nInserted: 1, ok: 1 } ]
|
|
107
110
|
// select then 4 len= 2
|
|
108
111
|
|
|
109
|
-
//node
|
|
112
|
+
//node g-mssql-concurrency.mjs
|
package/g-mssql-timerQuery.mjs
CHANGED
|
@@ -192,6 +192,9 @@ async function testCommit() {
|
|
|
192
192
|
|
|
193
193
|
}
|
|
194
194
|
testCommit()
|
|
195
|
+
.catch((err) => {
|
|
196
|
+
console.log(err)
|
|
197
|
+
})
|
|
195
198
|
// createStorage
|
|
196
199
|
// change delAll
|
|
197
200
|
// delAll then { n: 2, ok: 1 }
|
|
@@ -221,4 +224,4 @@ testCommit()
|
|
|
221
224
|
// ]
|
|
222
225
|
// commit success
|
|
223
226
|
|
|
224
|
-
//node
|
|
227
|
+
//node g-mssql-transaction-commit.mjs
|
|
@@ -189,6 +189,9 @@ async function testRollback() {
|
|
|
189
189
|
|
|
190
190
|
}
|
|
191
191
|
testRollback()
|
|
192
|
+
.catch((err) => {
|
|
193
|
+
console.log(err)
|
|
194
|
+
})
|
|
192
195
|
// createStorage
|
|
193
196
|
// change delAll
|
|
194
197
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -215,4 +218,4 @@ testRollback()
|
|
|
215
218
|
// select all (final) []
|
|
216
219
|
// rollback success
|
|
217
220
|
|
|
218
|
-
//node
|
|
221
|
+
//node g-mssql-transaction-rollback.mjs
|
package/g-mssql.mjs
CHANGED
|
@@ -156,6 +156,9 @@ async function test() {
|
|
|
156
156
|
|
|
157
157
|
}
|
|
158
158
|
test()
|
|
159
|
+
.catch((err) => {
|
|
160
|
+
console.log(err)
|
|
161
|
+
})
|
|
159
162
|
// createStorage
|
|
160
163
|
// change delAll
|
|
161
164
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -195,4 +198,4 @@ test()
|
|
|
195
198
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
196
199
|
// ]
|
|
197
200
|
|
|
198
|
-
//node
|
|
201
|
+
//node g-mssql.mjs
|
package/g-sqlite-concurrency.mjs
CHANGED
|
@@ -96,6 +96,9 @@ async function test() {
|
|
|
96
96
|
|
|
97
97
|
}
|
|
98
98
|
test()
|
|
99
|
+
.catch((err) => {
|
|
100
|
+
console.log(err)
|
|
101
|
+
})
|
|
99
102
|
// createStorage
|
|
100
103
|
// call save 1
|
|
101
104
|
// call select 2
|
|
@@ -106,4 +109,4 @@ test()
|
|
|
106
109
|
// save then 3 msg= [ { n: 1, nInserted: 1, ok: 1 } ]
|
|
107
110
|
// select then 4 len= 2
|
|
108
111
|
|
|
109
|
-
//node
|
|
112
|
+
//node g-sqlite-concurrency.mjs
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
// let w = wo(opt)
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
// //createStorage, create table for
|
|
63
|
+
// //createStorage, create table for sqlite
|
|
64
64
|
// await w.createStorage()
|
|
65
65
|
// console.log('createStorage')
|
|
66
66
|
|
|
@@ -190,7 +190,10 @@
|
|
|
190
190
|
|
|
191
191
|
// }
|
|
192
192
|
// testCommit()
|
|
193
|
+
// .catch((err) => {
|
|
194
|
+
// console.log(err)
|
|
195
|
+
// })
|
|
193
196
|
|
|
194
197
|
// @journeyapps/sqlcipher can not support transaction.
|
|
195
198
|
|
|
196
|
-
//node
|
|
199
|
+
//node g-sqlite-encryption-transaction-commit.mjs
|
package/g-sqlite-encryption.mjs
CHANGED
|
@@ -79,7 +79,7 @@ async function test() {
|
|
|
79
79
|
// })
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
//createStorage, create table for
|
|
82
|
+
//createStorage, create table for sqlite
|
|
83
83
|
await w.createStorage()
|
|
84
84
|
console.log('createStorage')
|
|
85
85
|
|
|
@@ -171,6 +171,9 @@ async function test() {
|
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
test()
|
|
174
|
+
.catch((err) => {
|
|
175
|
+
console.log(err)
|
|
176
|
+
})
|
|
174
177
|
// createStorage
|
|
175
178
|
// change delAll
|
|
176
179
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -210,4 +213,4 @@ test()
|
|
|
210
213
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
211
214
|
// ]
|
|
212
215
|
|
|
213
|
-
//node
|
|
216
|
+
//node g-sqlite-encryption.mjs
|
|
@@ -59,7 +59,7 @@ async function testCommit() {
|
|
|
59
59
|
let w = wo(opt)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
//createStorage, create table for
|
|
62
|
+
//createStorage, create table for sqlite
|
|
63
63
|
await w.createStorage()
|
|
64
64
|
console.log('createStorage')
|
|
65
65
|
|
|
@@ -199,6 +199,9 @@ async function testCommit() {
|
|
|
199
199
|
|
|
200
200
|
}
|
|
201
201
|
testCommit()
|
|
202
|
+
.catch((err) => {
|
|
203
|
+
console.log(err)
|
|
204
|
+
})
|
|
202
205
|
// createStorage
|
|
203
206
|
// change delAll
|
|
204
207
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -228,4 +231,4 @@ testCommit()
|
|
|
228
231
|
// ]
|
|
229
232
|
// commit success
|
|
230
233
|
|
|
231
|
-
//node
|
|
234
|
+
//node g-sqlite-transaction-commit.mjs
|
|
@@ -59,7 +59,7 @@ async function testRollback() {
|
|
|
59
59
|
let w = wo(opt)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
//createStorage, create table for
|
|
62
|
+
//createStorage, create table for sqlite
|
|
63
63
|
await w.createStorage()
|
|
64
64
|
console.log('createStorage')
|
|
65
65
|
|
|
@@ -196,6 +196,9 @@ async function testRollback() {
|
|
|
196
196
|
|
|
197
197
|
}
|
|
198
198
|
testRollback()
|
|
199
|
+
.catch((err) => {
|
|
200
|
+
console.log(err)
|
|
201
|
+
})
|
|
199
202
|
// createStorage
|
|
200
203
|
// change delAll
|
|
201
204
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -222,4 +225,4 @@ testRollback()
|
|
|
222
225
|
// select all (final) []
|
|
223
226
|
// rollback success
|
|
224
227
|
|
|
225
|
-
//node
|
|
228
|
+
//node g-sqlite-transaction-rollback.mjs
|
package/g-sqlite.mjs
CHANGED
|
@@ -72,7 +72,7 @@ async function test() {
|
|
|
72
72
|
// })
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
//createStorage, create table for
|
|
75
|
+
//createStorage, create table for sqlite
|
|
76
76
|
await w.createStorage()
|
|
77
77
|
console.log('createStorage')
|
|
78
78
|
|
|
@@ -164,6 +164,9 @@ async function test() {
|
|
|
164
164
|
|
|
165
165
|
}
|
|
166
166
|
test()
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
console.log(err)
|
|
169
|
+
})
|
|
167
170
|
// createStorage
|
|
168
171
|
// change delAll
|
|
169
172
|
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
@@ -203,4 +206,4 @@ test()
|
|
|
203
206
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
204
207
|
// ]
|
|
205
208
|
|
|
206
|
-
//node
|
|
209
|
+
//node g-sqlite.mjs
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-orm-reladb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"main": "dist/w-orm-reladb.umd.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"json5": "^2.2.3",
|
|
7
|
-
"lodash-es": "^4.
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"w-auto-sequelize": "^1.0.
|
|
11
|
-
"wsemi": "^1.
|
|
7
|
+
"lodash-es": "^4.18.1",
|
|
8
|
+
"sqlite3": "^6.0.1",
|
|
9
|
+
"tedious": "^19.2.2",
|
|
10
|
+
"w-auto-sequelize": "^1.0.28",
|
|
11
|
+
"wsemi": "^1.8.66"
|
|
12
12
|
},
|
|
13
13
|
"dependenciesTemp": {
|
|
14
14
|
"@journeyapps/sqlcipher": "^5.3.1",
|
|
15
15
|
"msg": "install sqlcipher fo the protection when db=sqlite"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"w-package-tools": "^1.
|
|
18
|
+
"w-package-tools": "^1.1.11"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"test": "mocha --parallel --timeout 60000
|
|
21
|
+
"test": "mocha --parallel --timeout 60000",
|
|
22
22
|
"deploy": "gh-pages -d docs"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
package/script.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#node
|
|
2
|
-
node
|
|
1
|
+
#node toolg/addVersion.mjs
|
|
2
|
+
node toolg/modifyReadme.mjs
|
|
3
3
|
|
|
4
|
-
node
|
|
4
|
+
node toolg/cleanFolder.mjs
|
|
5
5
|
./node_modules/.bin/jsdoc -c .jsdoc
|
|
6
6
|
|
|
7
|
-
node
|
|
7
|
+
node toolg/gDistRollup.mjs
|
|
8
8
|
|
|
9
9
|
git add . -A
|
|
10
10
|
git commit -m 'modify: '
|
package/src/WOrmReladb.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import events from 'events'
|
|
3
3
|
import Sequelize from 'sequelize'
|
|
4
|
-
import cloneDeep from 'lodash-es/cloneDeep.js'
|
|
5
|
-
import get from 'lodash-es/get.js'
|
|
6
|
-
import map from 'lodash-es/map.js'
|
|
7
|
-
import each from 'lodash-es/each.js'
|
|
8
|
-
import size from 'lodash-es/size.js'
|
|
9
|
-
import split from 'lodash-es/split.js'
|
|
4
|
+
import cloneDeep from 'lodash-es/cloneDeep.js'
|
|
5
|
+
import get from 'lodash-es/get.js'
|
|
6
|
+
import map from 'lodash-es/map.js'
|
|
7
|
+
import each from 'lodash-es/each.js'
|
|
8
|
+
import size from 'lodash-es/size.js'
|
|
9
|
+
import split from 'lodash-es/split.js'
|
|
10
10
|
import genPm from 'wsemi/src/genPm.mjs'
|
|
11
11
|
import genID from 'wsemi/src/genID.mjs'
|
|
12
12
|
import isarr from 'wsemi/src/isarr.mjs'
|
|
13
|
+
import isearr from 'wsemi/src/isearr.mjs'
|
|
13
14
|
import isobj from 'wsemi/src/isobj.mjs'
|
|
15
|
+
import iseobj from 'wsemi/src/iseobj.mjs'
|
|
14
16
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
15
17
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
16
18
|
import arrHas from 'wsemi/src/arrHas.mjs'
|
|
@@ -403,6 +405,15 @@ function WOrmReladb(opt = {}) {
|
|
|
403
405
|
*/
|
|
404
406
|
async function insert(data, option = {}) {
|
|
405
407
|
|
|
408
|
+
//check
|
|
409
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
410
|
+
return {
|
|
411
|
+
n: 0,
|
|
412
|
+
nInserted: 0,
|
|
413
|
+
ok: 1,
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
406
417
|
//instance
|
|
407
418
|
let instance = get(option, 'instance', null)
|
|
408
419
|
|
|
@@ -499,6 +510,11 @@ function WOrmReladb(opt = {}) {
|
|
|
499
510
|
*/
|
|
500
511
|
async function save(data, option = {}) {
|
|
501
512
|
|
|
513
|
+
//check
|
|
514
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
515
|
+
return []
|
|
516
|
+
}
|
|
517
|
+
|
|
502
518
|
//cloneDeep
|
|
503
519
|
data = cloneDeep(data)
|
|
504
520
|
|
|
@@ -694,6 +710,11 @@ function WOrmReladb(opt = {}) {
|
|
|
694
710
|
*/
|
|
695
711
|
async function del(data, option = {}) {
|
|
696
712
|
|
|
713
|
+
//check
|
|
714
|
+
if (!iseobj(data) && !isearr(data)) {
|
|
715
|
+
return []
|
|
716
|
+
}
|
|
717
|
+
|
|
697
718
|
//cloneDeep
|
|
698
719
|
data = cloneDeep(data)
|
|
699
720
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//共用測試數據, 對應g-mssql.mjs與g-sqlite.mjs之rs與rsm
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
//genRs, 初始插入數據, 第3筆id為空字串會自動產生主鍵
|
|
5
|
+
export let genRs = () => {
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
id: 'id-peter',
|
|
9
|
+
name: 'peter',
|
|
10
|
+
value: 123,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'id-rosemary',
|
|
14
|
+
name: 'rosemary',
|
|
15
|
+
value: 123.456,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: '',
|
|
19
|
+
name: 'kettle',
|
|
20
|
+
value: 456,
|
|
21
|
+
},
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
//genRsm, 儲存(修改)數據, 第3筆id為空字串需視autoInsert決定是否插入
|
|
27
|
+
export let genRsm = () => {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: 'id-peter',
|
|
31
|
+
name: 'peter(modify)',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'id-rosemary',
|
|
35
|
+
name: 'rosemary(modify)',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: '',
|
|
39
|
+
name: 'kettle(modify)',
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
//sortByName, select結果排序供穩定比對
|
|
46
|
+
export let sortByName = (rows) => {
|
|
47
|
+
return [...rows].sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
48
|
+
}
|