w-orm-reladb 1.1.7 → 1.1.8
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/w-orm-reladb.umd.js +2 -2
- package/dist/w-orm-reladb.umd.js.map +1 -1
- package/docs/WOrmReladb.html +10 -10
- package/docs/WOrmReladb.mjs.html +36 -22
- package/docs/cvFind.mjs.html +1 -1
- package/docs/global.html +1 -1
- package/docs/importModels.mjs.html +1 -1
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/WOrmReladb.mjs +35 -21
- package/src/requireModel.js +13 -5
- package/test/api-dist.test.mjs +112 -0
- package/test/api-init.test.mjs +50 -0
- package/toolg/gDistRollup.mjs +2 -0
package/docs/WOrmReladb.html
CHANGED
|
@@ -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#line1693">line 1693</a>
|
|
862
862
|
</li></ul></dd>
|
|
863
863
|
|
|
864
864
|
|
|
@@ -972,7 +972,7 @@
|
|
|
972
972
|
|
|
973
973
|
<dt class="tag-source">Source:</dt>
|
|
974
974
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
975
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
975
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1406">line 1406</a>
|
|
976
976
|
</li></ul></dd>
|
|
977
977
|
|
|
978
978
|
|
|
@@ -1304,7 +1304,7 @@
|
|
|
1304
1304
|
|
|
1305
1305
|
<dt class="tag-source">Source:</dt>
|
|
1306
1306
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1307
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
1307
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1595">line 1595</a>
|
|
1308
1308
|
</li></ul></dd>
|
|
1309
1309
|
|
|
1310
1310
|
|
|
@@ -1634,7 +1634,7 @@
|
|
|
1634
1634
|
|
|
1635
1635
|
<dt class="tag-source">Source:</dt>
|
|
1636
1636
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1637
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
1637
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1735">line 1735</a>
|
|
1638
1638
|
</li></ul></dd>
|
|
1639
1639
|
|
|
1640
1640
|
|
|
@@ -2162,7 +2162,7 @@
|
|
|
2162
2162
|
|
|
2163
2163
|
<dt class="tag-source">Source:</dt>
|
|
2164
2164
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2165
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2165
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1783">line 1783</a>
|
|
2166
2166
|
</li></ul></dd>
|
|
2167
2167
|
|
|
2168
2168
|
|
|
@@ -2762,7 +2762,7 @@
|
|
|
2762
2762
|
|
|
2763
2763
|
<dt class="tag-source">Source:</dt>
|
|
2764
2764
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
2765
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
2765
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line781">line 781</a>
|
|
2766
2766
|
</li></ul></dd>
|
|
2767
2767
|
|
|
2768
2768
|
|
|
@@ -3141,7 +3141,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
|
|
|
3141
3141
|
|
|
3142
3142
|
<dt class="tag-source">Source:</dt>
|
|
3143
3143
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3144
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
3144
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line957">line 957</a>
|
|
3145
3145
|
</li></ul></dd>
|
|
3146
3146
|
|
|
3147
3147
|
|
|
@@ -3475,7 +3475,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
|
|
|
3475
3475
|
|
|
3476
3476
|
<dt class="tag-source">Source:</dt>
|
|
3477
3477
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
3478
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
3478
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line1290">line 1290</a>
|
|
3479
3479
|
</li></ul></dd>
|
|
3480
3480
|
|
|
3481
3481
|
|
|
@@ -4184,7 +4184,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
|
|
|
4184
4184
|
|
|
4185
4185
|
<dt class="tag-source">Source:</dt>
|
|
4186
4186
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
4187
|
-
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#
|
|
4187
|
+
<a href="WOrmReladb.mjs.html">WOrmReladb.mjs</a>, <a href="WOrmReladb.mjs.html#line651">line 651</a>
|
|
4188
4188
|
</li></ul></dd>
|
|
4189
4189
|
|
|
4190
4190
|
|
|
@@ -4510,7 +4510,7 @@ mssql因綁定參數數量上限會由驅動層自動拆為多語句送出,實
|
|
|
4510
4510
|
<br class="clear">
|
|
4511
4511
|
|
|
4512
4512
|
<footer>
|
|
4513
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026
|
|
4513
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
4514
4514
|
</footer>
|
|
4515
4515
|
|
|
4516
4516
|
<script>prettyPrint();</script>
|
package/docs/WOrmReladb.mjs.html
CHANGED
|
@@ -618,15 +618,17 @@ function WOrmReladb(opt = {}) {
|
|
|
618
618
|
|
|
619
619
|
//si
|
|
620
620
|
let si = instance
|
|
621
|
-
if (instance === null) {
|
|
622
|
-
si = await initSequelize()
|
|
623
|
-
}
|
|
624
621
|
|
|
625
622
|
try {
|
|
626
623
|
|
|
627
624
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
628
625
|
procClosed(instance)
|
|
629
626
|
|
|
627
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
628
|
+
if (instance === null) {
|
|
629
|
+
si = await initSequelize()
|
|
630
|
+
}
|
|
631
|
+
|
|
630
632
|
//check, 連線或匯入models失敗影響本次操作之全部數據, 屬整批性錯誤
|
|
631
633
|
if (si.err) {
|
|
632
634
|
throw si.err
|
|
@@ -728,15 +730,17 @@ function WOrmReladb(opt = {}) {
|
|
|
728
730
|
|
|
729
731
|
//si
|
|
730
732
|
let si = instance
|
|
731
|
-
if (instance === null) {
|
|
732
|
-
si = await initSequelize()
|
|
733
|
-
}
|
|
734
733
|
|
|
735
734
|
try {
|
|
736
735
|
|
|
737
736
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
738
737
|
procClosed(instance)
|
|
739
738
|
|
|
739
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
740
|
+
if (instance === null) {
|
|
741
|
+
si = await initSequelize()
|
|
742
|
+
}
|
|
743
|
+
|
|
740
744
|
//check
|
|
741
745
|
if (si.err) {
|
|
742
746
|
throw si.err
|
|
@@ -860,15 +864,17 @@ function WOrmReladb(opt = {}) {
|
|
|
860
864
|
|
|
861
865
|
//si
|
|
862
866
|
let si = instance
|
|
863
|
-
if (instance === null) {
|
|
864
|
-
si = await initSequelize()
|
|
865
|
-
}
|
|
866
867
|
|
|
867
868
|
try {
|
|
868
869
|
|
|
869
870
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
870
871
|
procClosed(instance)
|
|
871
872
|
|
|
873
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
874
|
+
if (instance === null) {
|
|
875
|
+
si = await initSequelize()
|
|
876
|
+
}
|
|
877
|
+
|
|
872
878
|
//check
|
|
873
879
|
if (si.err) {
|
|
874
880
|
throw si.err
|
|
@@ -1028,15 +1034,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1028
1034
|
|
|
1029
1035
|
//si
|
|
1030
1036
|
let si = instance
|
|
1031
|
-
if (instance === null) {
|
|
1032
|
-
si = await initSequelize()
|
|
1033
|
-
}
|
|
1034
1037
|
|
|
1035
1038
|
try {
|
|
1036
1039
|
|
|
1037
1040
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1038
1041
|
procClosed(instance)
|
|
1039
1042
|
|
|
1043
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1044
|
+
if (instance === null) {
|
|
1045
|
+
si = await initSequelize()
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1040
1048
|
//check
|
|
1041
1049
|
if (si.err) {
|
|
1042
1050
|
throw si.err
|
|
@@ -1358,15 +1366,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1358
1366
|
|
|
1359
1367
|
//si
|
|
1360
1368
|
let si = instance
|
|
1361
|
-
if (instance === null) {
|
|
1362
|
-
si = await initSequelize()
|
|
1363
|
-
}
|
|
1364
1369
|
|
|
1365
1370
|
try {
|
|
1366
1371
|
|
|
1367
1372
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1368
1373
|
procClosed(instance)
|
|
1369
1374
|
|
|
1375
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1376
|
+
if (instance === null) {
|
|
1377
|
+
si = await initSequelize()
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1370
1380
|
//check
|
|
1371
1381
|
if (si.err) {
|
|
1372
1382
|
throw si.err
|
|
@@ -1469,15 +1479,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1469
1479
|
|
|
1470
1480
|
//si
|
|
1471
1481
|
let si = instance
|
|
1472
|
-
if (instance === null) {
|
|
1473
|
-
si = await initSequelize()
|
|
1474
|
-
}
|
|
1475
1482
|
|
|
1476
1483
|
try {
|
|
1477
1484
|
|
|
1478
1485
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1479
1486
|
procClosed(instance)
|
|
1480
1487
|
|
|
1488
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1489
|
+
if (instance === null) {
|
|
1490
|
+
si = await initSequelize()
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1481
1493
|
//check
|
|
1482
1494
|
if (si.err) {
|
|
1483
1495
|
throw si.err
|
|
@@ -1648,15 +1660,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1648
1660
|
|
|
1649
1661
|
//si
|
|
1650
1662
|
let si = instance
|
|
1651
|
-
if (instance === null) {
|
|
1652
|
-
si = await initSequelize()
|
|
1653
|
-
}
|
|
1654
1663
|
|
|
1655
1664
|
try {
|
|
1656
1665
|
|
|
1657
1666
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1658
1667
|
procClosed(instance)
|
|
1659
1668
|
|
|
1669
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1670
|
+
if (instance === null) {
|
|
1671
|
+
si = await initSequelize()
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1660
1674
|
//check
|
|
1661
1675
|
if (si.err) {
|
|
1662
1676
|
throw si.err
|
|
@@ -1883,7 +1897,7 @@ export default WOrmReladb
|
|
|
1883
1897
|
<br class="clear">
|
|
1884
1898
|
|
|
1885
1899
|
<footer>
|
|
1886
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026
|
|
1900
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1887
1901
|
</footer>
|
|
1888
1902
|
|
|
1889
1903
|
<script>prettyPrint();</script>
|
package/docs/cvFind.mjs.html
CHANGED
|
@@ -848,7 +848,7 @@ export default cvFind
|
|
|
848
848
|
<br class="clear">
|
|
849
849
|
|
|
850
850
|
<footer>
|
|
851
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026
|
|
851
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
852
852
|
</footer>
|
|
853
853
|
|
|
854
854
|
<script>prettyPrint();</script>
|
package/docs/global.html
CHANGED
|
@@ -1703,7 +1703,7 @@ DECIMAL主鍵欄之值小數位多於scale者寫入時會被四捨五入而改
|
|
|
1703
1703
|
<br class="clear">
|
|
1704
1704
|
|
|
1705
1705
|
<footer>
|
|
1706
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026
|
|
1706
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1707
1707
|
</footer>
|
|
1708
1708
|
|
|
1709
1709
|
<script>prettyPrint();</script>
|
|
@@ -242,7 +242,7 @@ export default importModels
|
|
|
242
242
|
<br class="clear">
|
|
243
243
|
|
|
244
244
|
<footer>
|
|
245
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026
|
|
245
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
246
246
|
</footer>
|
|
247
247
|
|
|
248
248
|
<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.5</a> on Fri Oct 16 2026
|
|
74
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Fri Oct 16 2026 14:32:44 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/package.json
CHANGED
package/src/WOrmReladb.mjs
CHANGED
|
@@ -571,15 +571,17 @@ function WOrmReladb(opt = {}) {
|
|
|
571
571
|
|
|
572
572
|
//si
|
|
573
573
|
let si = instance
|
|
574
|
-
if (instance === null) {
|
|
575
|
-
si = await initSequelize()
|
|
576
|
-
}
|
|
577
574
|
|
|
578
575
|
try {
|
|
579
576
|
|
|
580
577
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
581
578
|
procClosed(instance)
|
|
582
579
|
|
|
580
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
581
|
+
if (instance === null) {
|
|
582
|
+
si = await initSequelize()
|
|
583
|
+
}
|
|
584
|
+
|
|
583
585
|
//check, 連線或匯入models失敗影響本次操作之全部數據, 屬整批性錯誤
|
|
584
586
|
if (si.err) {
|
|
585
587
|
throw si.err
|
|
@@ -681,15 +683,17 @@ function WOrmReladb(opt = {}) {
|
|
|
681
683
|
|
|
682
684
|
//si
|
|
683
685
|
let si = instance
|
|
684
|
-
if (instance === null) {
|
|
685
|
-
si = await initSequelize()
|
|
686
|
-
}
|
|
687
686
|
|
|
688
687
|
try {
|
|
689
688
|
|
|
690
689
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
691
690
|
procClosed(instance)
|
|
692
691
|
|
|
692
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
693
|
+
if (instance === null) {
|
|
694
|
+
si = await initSequelize()
|
|
695
|
+
}
|
|
696
|
+
|
|
693
697
|
//check
|
|
694
698
|
if (si.err) {
|
|
695
699
|
throw si.err
|
|
@@ -813,15 +817,17 @@ function WOrmReladb(opt = {}) {
|
|
|
813
817
|
|
|
814
818
|
//si
|
|
815
819
|
let si = instance
|
|
816
|
-
if (instance === null) {
|
|
817
|
-
si = await initSequelize()
|
|
818
|
-
}
|
|
819
820
|
|
|
820
821
|
try {
|
|
821
822
|
|
|
822
823
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
823
824
|
procClosed(instance)
|
|
824
825
|
|
|
826
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
827
|
+
if (instance === null) {
|
|
828
|
+
si = await initSequelize()
|
|
829
|
+
}
|
|
830
|
+
|
|
825
831
|
//check
|
|
826
832
|
if (si.err) {
|
|
827
833
|
throw si.err
|
|
@@ -981,15 +987,17 @@ function WOrmReladb(opt = {}) {
|
|
|
981
987
|
|
|
982
988
|
//si
|
|
983
989
|
let si = instance
|
|
984
|
-
if (instance === null) {
|
|
985
|
-
si = await initSequelize()
|
|
986
|
-
}
|
|
987
990
|
|
|
988
991
|
try {
|
|
989
992
|
|
|
990
993
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
991
994
|
procClosed(instance)
|
|
992
995
|
|
|
996
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
997
|
+
if (instance === null) {
|
|
998
|
+
si = await initSequelize()
|
|
999
|
+
}
|
|
1000
|
+
|
|
993
1001
|
//check
|
|
994
1002
|
if (si.err) {
|
|
995
1003
|
throw si.err
|
|
@@ -1311,15 +1319,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1311
1319
|
|
|
1312
1320
|
//si
|
|
1313
1321
|
let si = instance
|
|
1314
|
-
if (instance === null) {
|
|
1315
|
-
si = await initSequelize()
|
|
1316
|
-
}
|
|
1317
1322
|
|
|
1318
1323
|
try {
|
|
1319
1324
|
|
|
1320
1325
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1321
1326
|
procClosed(instance)
|
|
1322
1327
|
|
|
1328
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1329
|
+
if (instance === null) {
|
|
1330
|
+
si = await initSequelize()
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1323
1333
|
//check
|
|
1324
1334
|
if (si.err) {
|
|
1325
1335
|
throw si.err
|
|
@@ -1422,15 +1432,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1422
1432
|
|
|
1423
1433
|
//si
|
|
1424
1434
|
let si = instance
|
|
1425
|
-
if (instance === null) {
|
|
1426
|
-
si = await initSequelize()
|
|
1427
|
-
}
|
|
1428
1435
|
|
|
1429
1436
|
try {
|
|
1430
1437
|
|
|
1431
1438
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1432
1439
|
procClosed(instance)
|
|
1433
1440
|
|
|
1441
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1442
|
+
if (instance === null) {
|
|
1443
|
+
si = await initSequelize()
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1434
1446
|
//check
|
|
1435
1447
|
if (si.err) {
|
|
1436
1448
|
throw si.err
|
|
@@ -1601,15 +1613,17 @@ function WOrmReladb(opt = {}) {
|
|
|
1601
1613
|
|
|
1602
1614
|
//si
|
|
1603
1615
|
let si = instance
|
|
1604
|
-
if (instance === null) {
|
|
1605
|
-
si = await initSequelize()
|
|
1606
|
-
}
|
|
1607
1616
|
|
|
1608
1617
|
try {
|
|
1609
1618
|
|
|
1610
1619
|
//check, 實例已關閉屬整批性錯誤, 於入口快速失敗
|
|
1611
1620
|
procClosed(instance)
|
|
1612
1621
|
|
|
1622
|
+
//initSequelize, 內部自動初始化須在try內: 其例外(如驅動缺失)與si.err同屬整批性錯誤, 方能於reject前發出error事件, 已建構之sequelize亦由finally關閉
|
|
1623
|
+
if (instance === null) {
|
|
1624
|
+
si = await initSequelize()
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1613
1627
|
//check
|
|
1614
1628
|
if (si.err) {
|
|
1615
1629
|
throw si.err
|
package/src/requireModel.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const { createRequire } = require('module')
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
//載入js格式之model檔並呼叫其定義函數
|
|
5
|
+
//註: 不可直接以require(fn)載入: 發布用dist經rollup之commonjs外掛打包時, 引數非字面值之require會被換成必拋[Could not dynamically require]之樁,
|
|
6
|
+
//故以Node內建module之createRequire依model檔之絕對路徑產生require函數載入, 其解析與模組快取皆同require
|
|
7
|
+
//註: fn須為絕對路徑, 呼叫端(本套件與w-orm-mdb之importModels)皆以path.resolve產生; 被w-orm-mdb等深層引用, 勿改簽章或路徑
|
|
8
|
+
function requireModel(fn, sequelize, DataTypes) {
|
|
9
|
+
let req = createRequire(fn)
|
|
10
|
+
return req(fn)(sequelize, DataTypes)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = requireModel
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
import { execFile } from 'child_process'
|
|
5
|
+
import { createRequire } from 'module'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
//rulebook R10: 經package.json之main(dist)使用時, js型model之importModels與各函數須與經src使用時同樣可用
|
|
9
|
+
//修正前dist內src/requireModel.js之require(fn)被rollup之commonjs外掛換成必拋[Could not dynamically require]之樁, 而測試只跑src未曾發現
|
|
10
|
+
//作法: 以toolg/gDistRollup.mjs原檔之設定只換輸出夾, 由目前src建置至已安裝佈局(app/node_modules/w-orm-reladb/dist), 再由app以套件名require
|
|
11
|
+
//僅以sqlite驗證, 因model檔之載入與資料庫種類無關
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
let fd = './test/_tmp/api-dist'
|
|
15
|
+
let fdApp = `${fd}/app`
|
|
16
|
+
let fdPkg = `${fdApp}/node_modules/w-orm-reladb`
|
|
17
|
+
let fdDist = `${fdPkg}/dist`
|
|
18
|
+
let fdModels = `${fd}/models`
|
|
19
|
+
let fpBundle = `${fdDist}/w-orm-reladb.umd.js`
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
//buildDist, 複製gDistRollup.mjs並只把fdTar換成已安裝佈局之dist後, 以子行程於專案根目錄執行(同發布時之cwd, 故babel.config.js與package.json同發布)
|
|
23
|
+
let buildDist = () => {
|
|
24
|
+
let c = fs.readFileSync('./toolg/gDistRollup.mjs', 'utf8')
|
|
25
|
+
let from = `let fdTar = './dist'`
|
|
26
|
+
assert.strictEqual(c.split(from).length - 1, 1, `toolg/gDistRollup.mjs須恰有一處[${from}]供替換輸出夾`)
|
|
27
|
+
c = c.replace(from, `let fdTar = '${fdDist}'`)
|
|
28
|
+
let fpGen = `${fd}/gDistRollup.mjs`
|
|
29
|
+
fs.writeFileSync(fpGen, c, 'utf8')
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
execFile(process.execPath, [fpGen], { maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
|
|
32
|
+
if (err) {
|
|
33
|
+
reject(new Error(`build dist failed: ${err.message}\n${stderr}`))
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
resolve(stdout)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
describe('dist (installed layout)', function() {
|
|
43
|
+
|
|
44
|
+
let wo = null
|
|
45
|
+
|
|
46
|
+
before(async function() {
|
|
47
|
+
|
|
48
|
+
fs.rmSync(fd, { recursive: true, force: true })
|
|
49
|
+
fs.mkdirSync(fdDist, { recursive: true })
|
|
50
|
+
|
|
51
|
+
//build
|
|
52
|
+
await buildDist()
|
|
53
|
+
|
|
54
|
+
//已安裝佈局: 套件夾內之package.json(main指向dist), 相依(sequelize等)沿上層node_modules解析
|
|
55
|
+
fs.copyFileSync('./package.json', `${fdPkg}/package.json`)
|
|
56
|
+
|
|
57
|
+
//models, 複製至暫存夾, 不動版控中之models
|
|
58
|
+
fs.mkdirSync(fdModels, { recursive: true })
|
|
59
|
+
fs.copyFileSync('./models/users.js', `${fdModels}/users.js`)
|
|
60
|
+
fs.copyFileSync('./models/users.json', `${fdModels}/users.json`)
|
|
61
|
+
|
|
62
|
+
//require, 由app以套件名解析
|
|
63
|
+
let req = createRequire(path.resolve(fdApp, 'index.js'))
|
|
64
|
+
assert.strictEqual(req.resolve('w-orm-reladb'), path.resolve(fpBundle), '套件名須經package.json之main解析至建出之dist')
|
|
65
|
+
wo = req('w-orm-reladb')
|
|
66
|
+
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
after(function() {
|
|
70
|
+
fs.rmSync(fd, { recursive: true, force: true })
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('建出之dist不含rollup動態require之樁', function() {
|
|
74
|
+
//rulebook R10: 建置產物不得含[Could not dynamically require](含被打包之相依)
|
|
75
|
+
let code = fs.readFileSync(fpBundle, 'utf8')
|
|
76
|
+
assert.ok(code.length > 0)
|
|
77
|
+
assert.strictEqual(code.indexOf('Could not dynamically require'), -1)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('js型model: createStorage、insert、select、selectByPk、del皆成功且不發error事件', async function() {
|
|
81
|
+
//rulebook R10: 預設modelType為js, 經main使用時importModels須可載入js型model
|
|
82
|
+
assert.strictEqual(typeof wo, 'function')
|
|
83
|
+
let w = wo({ url: 'sqlite://:', db: 'worm', cl: 'users', fdModels, storage: `${fd}/js.sqlite` })
|
|
84
|
+
let errs = []
|
|
85
|
+
w.on('error', (mode, data, err) => {
|
|
86
|
+
errs.push([mode, err])
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
assert.strictEqual(await w.createStorage(), 'created')
|
|
90
|
+
assert.deepStrictEqual(await w.insert({ id: 'a1', name: 'A', value: 1.5 }), { n: 1, nInserted: 1, ok: 1 })
|
|
91
|
+
assert.deepStrictEqual(await w.select({ id: 'a1' }), [{ id: 'a1', name: 'A', value: 1.5 }])
|
|
92
|
+
assert.deepStrictEqual(await w.selectByPk('a1'), { id: 'a1', name: 'A', value: 1.5 })
|
|
93
|
+
assert.deepStrictEqual(await w.del({ id: 'a1' }), [{ n: 1, nDeleted: 1, ok: 1 }])
|
|
94
|
+
assert.deepStrictEqual(await w.select(), [])
|
|
95
|
+
assert.deepStrictEqual(errs, [])
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('json型model(對照): createStorage、insert、select皆成功且不發error事件', async function() {
|
|
99
|
+
//rulebook R10: 兩種modelType經main皆須可用; json型不經requireModel, 修正前即可用
|
|
100
|
+
let w = wo({ url: 'sqlite://:', db: 'worm', cl: 'users', fdModels, modelType: 'json', storage: `${fd}/json.sqlite` })
|
|
101
|
+
let errs = []
|
|
102
|
+
w.on('error', (mode, data, err) => {
|
|
103
|
+
errs.push([mode, err])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
assert.strictEqual(await w.createStorage(), 'created')
|
|
107
|
+
assert.deepStrictEqual(await w.insert({ id: 'b1', name: 'B', value: 2 }), { n: 1, nInserted: 1, ok: 1 })
|
|
108
|
+
assert.deepStrictEqual(await w.select({ id: 'b1' }), [{ id: 'b1', name: 'B', value: 2 }])
|
|
109
|
+
assert.deepStrictEqual(errs, [])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import wo from '../src/WOrmReladb.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
//rulebook R7: 七函數之內部初始化(initSequelize)在主try內, 其建構期例外與其他整批性錯誤同樣於reject前發一次error事件(規格T10.3)
|
|
6
|
+
//觸發: 本套件不相依mysql2, 以mysql://建構sequelize時即拋[Please install mysql2 package manually]; 若環境另裝mysql2則前提不成立, 斷言訊息會指出
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe('initSequelize throws', function() {
|
|
10
|
+
|
|
11
|
+
it('七函數皆reject, 且於reject前各發一次error事件, mode為函數名、data為輸入數據或null、err與reject訊息一致', async function() {
|
|
12
|
+
let w = wo({ url: 'mysql://username:password@localhost:3306', db: 'worm', cl: 'users', fdModels: './models' })
|
|
13
|
+
let settled = false
|
|
14
|
+
let evs = []
|
|
15
|
+
w.on('error', (mode, data, err) => {
|
|
16
|
+
evs.push({ mode, data, err, settled })
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
let cases = [
|
|
20
|
+
['select', null, () => w.select({ id: 'k1' })],
|
|
21
|
+
['selectByPk', null, () => w.selectByPk('k1')],
|
|
22
|
+
['insert', { id: 'k1', name: 'A' }, (d) => w.insert(d)],
|
|
23
|
+
['insertBulk', [{ id: 'k2', name: 'B' }], (d) => w.insertBulk(d)],
|
|
24
|
+
['save', [{ id: 'k1', name: 'Z' }], (d) => w.save(d)],
|
|
25
|
+
['del', [{ id: 'k1' }], (d) => w.del(d)],
|
|
26
|
+
['delAll', null, () => w.delAll({ id: 'k1' })],
|
|
27
|
+
]
|
|
28
|
+
for (let [mode, data, fn] of cases) {
|
|
29
|
+
settled = false
|
|
30
|
+
evs = []
|
|
31
|
+
let r = await fn(data)
|
|
32
|
+
.then((v) => ({ RESOLVE: v }), (err) => ({ REJECT: String(err.message || err) }))
|
|
33
|
+
.finally(() => {
|
|
34
|
+
settled = true
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
//整批性錯誤經Promise.reject(規格T4)
|
|
38
|
+
assert.ok(r.REJECT !== undefined, `${mode} 未reject, 實得 ${JSON.stringify(r.RESOLVE)}`)
|
|
39
|
+
assert.ok(r.REJECT.indexOf('Please install mysql2') >= 0, `${mode} 之reject非建構期例外(前提: 本機未裝mysql2): ${r.REJECT}`)
|
|
40
|
+
|
|
41
|
+
//規格T10.3: 整批性錯誤於reject之前發出一次, mode取函數名, err與reject之訊息一致, data為本次輸入數據(無輸入數據者為null)
|
|
42
|
+
assert.strictEqual(evs.length, 1, `${mode} 之error事件數 ${evs.length}`)
|
|
43
|
+
assert.strictEqual(evs[0].mode, mode)
|
|
44
|
+
assert.strictEqual(evs[0].err, r.REJECT)
|
|
45
|
+
assert.deepStrictEqual(evs[0].data, data)
|
|
46
|
+
assert.strictEqual(evs[0].settled, false, `${mode} 之error事件須於reject之前發出`)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
})
|
package/toolg/gDistRollup.mjs
CHANGED
|
@@ -15,6 +15,7 @@ rollupFiles({
|
|
|
15
15
|
'events': 'events',
|
|
16
16
|
'fs': 'fs',
|
|
17
17
|
'path': 'path',
|
|
18
|
+
'module': 'module', //src/requireModel.js以module之createRequire載入model檔
|
|
18
19
|
'sequelize': 'sequelize',
|
|
19
20
|
'mssql': 'mssql',
|
|
20
21
|
'sqlite': 'sqlite',
|
|
@@ -25,6 +26,7 @@ rollupFiles({
|
|
|
25
26
|
'events',
|
|
26
27
|
'fs',
|
|
27
28
|
'path',
|
|
29
|
+
'module',
|
|
28
30
|
'sequelize',
|
|
29
31
|
'mssql',
|
|
30
32
|
'sqlite',
|