w-orm-lowdb 1.0.12 → 1.0.14
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 +121 -15
- package/dist/w-orm-lowdb.umd.js +2 -2
- package/dist/w-orm-lowdb.umd.js.map +1 -1
- package/docs/WOrmLowdb.html +628 -27
- package/docs/WOrmLowdb.mjs.html +1068 -779
- package/docs/index.html +2 -2
- package/g-basic.mjs +203 -185
- package/package.json +3 -3
- package/src/WOrmLowdb.mjs +1066 -777
- package/test/lib/procConcurrency.mjs +53 -0
- package/test/unit-autogenpk.test.mjs +205 -0
- package/test/{basic.test.mjs → unit-basic.test.mjs} +51 -54
- package/test/{cache.test.mjs → unit-cache.test.mjs} +2 -2
- package/test/unit-concurrency.test.mjs +140 -0
- package/test/unit-del.test.mjs +140 -0
- package/test/unit-delall.test.mjs +153 -0
- package/test/unit-event.test.mjs +252 -0
- package/test/unit-insert.test.mjs +120 -0
- package/test/unit-insertbulk.test.mjs +188 -0
- package/test/unit-returnlist.test.mjs +159 -0
- package/test/unit-save.test.mjs +199 -0
- package/test/unit-selectbypk.test.mjs +121 -0
- package/toolg/gDistRollup.mjs +3 -3
package/docs/WOrmLowdb.html
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="WOrmLowdb.html">WOrmLowdb</a><ul class='methods'><li data-type='method'><a href="WOrmLowdb.html#.delAllCore">delAllCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.delCore">delCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.insertCore">insertCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.saveCore">saveCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.selectCore">selectCore</a></li></ul></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="WOrmLowdb.html">WOrmLowdb</a><ul class='methods'><li data-type='method'><a href="WOrmLowdb.html#.delAllCore">delAllCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.delCore">delCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.insertBulkCore">insertBulkCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.insertCore">insertCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.saveCore">saveCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.selectByPkCore">selectByPkCore</a></li><li data-type='method'><a href="WOrmLowdb.html#.selectCore">selectCore</a></li><li data-type='method'><a href="WOrmLowdb.html#~serialize">serialize</a></li></ul></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -74,13 +74,30 @@
|
|
|
74
74
|
<dl class="details">
|
|
75
75
|
|
|
76
76
|
<dt class="tag-description">Description:</dt>
|
|
77
|
-
<dd class="tag-description"><ul class="dummy"><li><p>操作資料庫(lowdb)</p
|
|
77
|
+
<dd class="tag-description"><ul class="dummy"><li><p>操作資料庫(lowdb)</p>
|
|
78
|
+
<p>回傳物件為EventEmitter,除各操作函數外另發出change與error兩事件,供呼叫端於單一處集中觀察資料異動與失敗。
|
|
79
|
+
事件僅為附加通知,其所送出之資訊皆另有正規管道(操作結果經resolve、整批性錯誤經reject、逐筆失敗經該筆之err欄位),
|
|
80
|
+
故不監聽亦能取得完整資訊,且監聽與否不改變任何操作之回傳值。</p>
|
|
81
|
+
<p>change事件,參數為(mode, data, res),於資料實際異動成功後發出:
|
|
82
|
+
mode為操作別字串,可為'insert'、'insertBulk'、'save'、'del'、'delAll';save內若逐筆走自動插入則該筆另發出mode為'insert'之事件。
|
|
83
|
+
data為本次操作之輸入數據,delAll固定為null。
|
|
84
|
+
res為本次操作之回傳結果。
|
|
85
|
+
逐筆函數以整批為單位發出一次而不逐筆發出,select與selectByPk不發出本事件。</p>
|
|
86
|
+
<p>error事件,參數為(mode, data, err),於操作發生錯誤時發出:
|
|
87
|
+
mode為操作別字串,可為'select'、'selectByPk'、'insert'、'insertBulk'、'save'、'del'、'delAll'。
|
|
88
|
+
data為本次操作之輸入數據,無輸入數據者為null。
|
|
89
|
+
err為錯誤訊息字串,內容與正規管道所送出者一致。
|
|
90
|
+
整批性錯誤於reject之前發出;逐筆失敗於該筆結果定案後發出,每筆一次。
|
|
91
|
+
註: 逐筆失敗時整批仍resolve,故收到本事件不表示該次呼叫失敗;正常結果(如查無數據、主鍵未命中、全數已存在)不發出本事件。</p>
|
|
92
|
+
<p>註: 本套件之主鍵欄位固定為id,尚未支援指定其他欄位為主鍵。
|
|
93
|
+
註: 本套件之寫入為[整檔讀出、記憶體修改、整檔寫回],其原子性由行程內之序列化佇列提供,
|
|
94
|
+
故僅單一行程內併發成立,跨行程併發不成立,詳見README之併發保證宣告。</p></li></ul></dd>
|
|
78
95
|
|
|
79
96
|
|
|
80
97
|
|
|
81
98
|
<dt class="tag-source">Source:</dt>
|
|
82
99
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
83
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
100
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line61">line 61</a>
|
|
84
101
|
</li></ul></dd>
|
|
85
102
|
|
|
86
103
|
|
|
@@ -376,6 +393,46 @@
|
|
|
376
393
|
</tr>
|
|
377
394
|
|
|
378
395
|
|
|
396
|
+
|
|
397
|
+
<tr>
|
|
398
|
+
|
|
399
|
+
<td class="name"><code>autoGenPk</code></td>
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
<td class="type">
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
<span class="param-type">Boolean</span>
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
</td>
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
<td class="attributes">
|
|
414
|
+
|
|
415
|
+
<optional><br>
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
</td>
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
<td class="default">
|
|
426
|
+
|
|
427
|
+
<code>true</code>
|
|
428
|
+
|
|
429
|
+
</td>
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
<td class="description last"><p>輸入insert、insertBulk與save於數據未帶有效主鍵(本套件為id欄位)時是否自動產生主鍵值,預設true;給false代表主鍵改由呼叫端自備,套件不產生亦不檢查其唯一性與格式,未帶有效主鍵者將reject</p></td>
|
|
433
|
+
</tr>
|
|
434
|
+
|
|
435
|
+
|
|
379
436
|
</tbody>
|
|
380
437
|
</table>
|
|
381
438
|
|
|
@@ -469,7 +526,7 @@
|
|
|
469
526
|
|
|
470
527
|
<dt class="tag-source">Source:</dt>
|
|
471
528
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
472
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
529
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line971">line 971</a>
|
|
473
530
|
</li></ul></dd>
|
|
474
531
|
|
|
475
532
|
|
|
@@ -604,7 +661,7 @@
|
|
|
604
661
|
|
|
605
662
|
|
|
606
663
|
<div class="param-desc">
|
|
607
|
-
<p>回傳Promise,resolve
|
|
664
|
+
<p>回傳Promise,resolve回傳刪除結果物件{n,nDeleted,ok},n與nDeleted同為實際刪除筆數,reject回傳錯誤訊息</p>
|
|
608
665
|
</div>
|
|
609
666
|
|
|
610
667
|
|
|
@@ -641,13 +698,13 @@
|
|
|
641
698
|
<dl class="details">
|
|
642
699
|
|
|
643
700
|
<dt class="tag-description">Description:</dt>
|
|
644
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
701
|
+
<dd class="tag-description"><ul class="dummy"><li><p>刪除數據,依主鍵刪除</p></li></ul></dd>
|
|
645
702
|
|
|
646
703
|
|
|
647
704
|
|
|
648
705
|
<dt class="tag-source">Source:</dt>
|
|
649
706
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
650
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
707
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line813">line 813</a>
|
|
651
708
|
</li></ul></dd>
|
|
652
709
|
|
|
653
710
|
|
|
@@ -765,7 +822,7 @@
|
|
|
765
822
|
|
|
766
823
|
|
|
767
824
|
<div class="param-desc">
|
|
768
|
-
<p>回傳Promise,resolve
|
|
825
|
+
<p>回傳Promise,resolve回傳與輸入等長之刪除結果陣列,各筆為{n,nDeleted,ok},n為主鍵命中筆數,單筆失敗或未給有效id者ok為0並附err,reject回傳錯誤訊息</p>
|
|
769
826
|
</div>
|
|
770
827
|
|
|
771
828
|
|
|
@@ -792,7 +849,7 @@
|
|
|
792
849
|
|
|
793
850
|
|
|
794
851
|
|
|
795
|
-
<h4 class="name" id=".
|
|
852
|
+
<h4 class="name" id=".insertBulkCore"><span class="type-signature type-signature-async, static">(async, static) </span>insertBulkCore<span class="signature">(data)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
796
853
|
|
|
797
854
|
|
|
798
855
|
|
|
@@ -802,13 +859,17 @@
|
|
|
802
859
|
<dl class="details">
|
|
803
860
|
|
|
804
861
|
<dt class="tag-description">Description:</dt>
|
|
805
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
862
|
+
<dd class="tag-description"><ul class="dummy"><li><p>批次插入數據,全批視為一個單位,全部插入成功或一筆都不寫入
|
|
863
|
+
註: 本函數非insert之加速版,兩者衝突政策不同。insert於主鍵已存在時跳過該筆而整批ok為1,
|
|
864
|
+
本函數則整批reject且不寫入任何一筆;同批含重複主鍵者亦視為衝突。確無衝突時兩者結果相同
|
|
865
|
+
註: 於本套件不會較insert快,因兩者皆為一次讀檔與一次寫檔,
|
|
866
|
+
提供本函數係為與其他w-orm系列套件維持同一組函數,令呼叫端得於各套件間替換而不須改寫呼叫</p></li></ul></dd>
|
|
806
867
|
|
|
807
868
|
|
|
808
869
|
|
|
809
870
|
<dt class="tag-source">Source:</dt>
|
|
810
871
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
811
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
872
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line516">line 516</a>
|
|
812
873
|
</li></ul></dd>
|
|
813
874
|
|
|
814
875
|
|
|
@@ -926,7 +987,7 @@
|
|
|
926
987
|
|
|
927
988
|
|
|
928
989
|
<div class="param-desc">
|
|
929
|
-
<p>回傳Promise,resolve
|
|
990
|
+
<p>回傳Promise,resolve回傳插入結果物件{n,nInserted,ok},n為輸入筆數、nInserted成功時恆等於n,任一筆主鍵已存在則reject回傳錯誤訊息</p>
|
|
930
991
|
</div>
|
|
931
992
|
|
|
932
993
|
|
|
@@ -953,7 +1014,7 @@
|
|
|
953
1014
|
|
|
954
1015
|
|
|
955
1016
|
|
|
956
|
-
<h4 class="name" id=".
|
|
1017
|
+
<h4 class="name" id=".insertCore"><span class="type-signature type-signature-async, static">(async, static) </span>insertCore<span class="signature">(data, option<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
957
1018
|
|
|
958
1019
|
|
|
959
1020
|
|
|
@@ -963,13 +1024,13 @@
|
|
|
963
1024
|
<dl class="details">
|
|
964
1025
|
|
|
965
1026
|
<dt class="tag-description">Description:</dt>
|
|
966
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
1027
|
+
<dd class="tag-description"><ul class="dummy"><li><p>插入數據,僅於主鍵不存在時寫入,已存在者跳過且不覆寫</p></li></ul></dd>
|
|
967
1028
|
|
|
968
1029
|
|
|
969
1030
|
|
|
970
1031
|
<dt class="tag-source">Source:</dt>
|
|
971
1032
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
972
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
1033
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line382">line 382</a>
|
|
973
1034
|
</li></ul></dd>
|
|
974
1035
|
|
|
975
1036
|
|
|
@@ -1147,13 +1208,13 @@
|
|
|
1147
1208
|
|
|
1148
1209
|
<tr>
|
|
1149
1210
|
|
|
1150
|
-
<td class="name"><code>
|
|
1211
|
+
<td class="name"><code>returnList</code></td>
|
|
1151
1212
|
|
|
1152
1213
|
|
|
1153
1214
|
<td class="type">
|
|
1154
1215
|
|
|
1155
1216
|
|
|
1156
|
-
<span class="param-type">
|
|
1217
|
+
<span class="param-type">Boolean</span>
|
|
1157
1218
|
|
|
1158
1219
|
|
|
1159
1220
|
|
|
@@ -1175,12 +1236,12 @@
|
|
|
1175
1236
|
|
|
1176
1237
|
<td class="default">
|
|
1177
1238
|
|
|
1178
|
-
<code>
|
|
1239
|
+
<code>false</code>
|
|
1179
1240
|
|
|
1180
1241
|
</td>
|
|
1181
1242
|
|
|
1182
1243
|
|
|
1183
|
-
<td class="description last"><p
|
|
1244
|
+
<td class="description last"><p>輸入是否改回傳逐筆結果布林值,預設false。給true時回傳與輸入等長保序之陣列,各筆為{n,nInserted,ok},nInserted為1即該筆為新增;聚合計數只回答有幾筆是新的,逐筆結果方能回答是哪幾筆,供下游僅對新資料執行昂貴動作。回傳形式由呼叫點靜態決定,共用之結果處理程式碼不可跨不同取值之呼叫點混用</p></td>
|
|
1184
1245
|
</tr>
|
|
1185
1246
|
|
|
1186
1247
|
|
|
@@ -1213,7 +1274,7 @@
|
|
|
1213
1274
|
|
|
1214
1275
|
|
|
1215
1276
|
<div class="param-desc">
|
|
1216
|
-
<p>回傳Promise,resolve
|
|
1277
|
+
<p>回傳Promise,resolve依returnList回傳插入結果:預設回傳聚合物件{n,nInserted,ok},n為輸入筆數、nInserted為實際插入筆數;returnList為true時回傳逐筆陣列,各筆n恆為1(主鍵命中或經插入)、ok恆為1(insert之錯誤皆屬整批性而reject,不進逐筆);reject回傳錯誤訊息</p>
|
|
1217
1278
|
</div>
|
|
1218
1279
|
|
|
1219
1280
|
|
|
@@ -1240,7 +1301,7 @@
|
|
|
1240
1301
|
|
|
1241
1302
|
|
|
1242
1303
|
|
|
1243
|
-
<h4 class="name" id=".
|
|
1304
|
+
<h4 class="name" id=".saveCore"><span class="type-signature type-signature-async, static">(async, static) </span>saveCore<span class="signature">(data, option<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
1244
1305
|
|
|
1245
1306
|
|
|
1246
1307
|
|
|
@@ -1250,13 +1311,13 @@
|
|
|
1250
1311
|
<dl class="details">
|
|
1251
1312
|
|
|
1252
1313
|
<dt class="tag-description">Description:</dt>
|
|
1253
|
-
<dd class="tag-description"><ul class="dummy"><li><p
|
|
1314
|
+
<dd class="tag-description"><ul class="dummy"><li><p>儲存數據,以主鍵為準更新既有數據,未給之欄位保留;主鍵不存在且autoInsert為true時改為插入</p></li></ul></dd>
|
|
1254
1315
|
|
|
1255
1316
|
|
|
1256
1317
|
|
|
1257
1318
|
<dt class="tag-source">Source:</dt>
|
|
1258
1319
|
<dd class="tag-source"><ul class="dummy"><li>
|
|
1259
|
-
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#
|
|
1320
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line617">line 617</a>
|
|
1260
1321
|
</li></ul></dd>
|
|
1261
1322
|
|
|
1262
1323
|
|
|
@@ -1332,7 +1393,46 @@
|
|
|
1332
1393
|
|
|
1333
1394
|
<tr>
|
|
1334
1395
|
|
|
1335
|
-
<td class="name"><code>
|
|
1396
|
+
<td class="name"><code>data</code></td>
|
|
1397
|
+
|
|
1398
|
+
|
|
1399
|
+
<td class="type">
|
|
1400
|
+
|
|
1401
|
+
|
|
1402
|
+
<span class="param-type">Object</span>
|
|
1403
|
+
|
|
|
1404
|
+
|
|
1405
|
+
<span class="param-type">Array</span>
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
</td>
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
<td class="attributes">
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
</td>
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
<td class="default">
|
|
1424
|
+
|
|
1425
|
+
</td>
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
<td class="description last"><p>輸入數據物件或陣列</p></td>
|
|
1429
|
+
</tr>
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
<tr>
|
|
1434
|
+
|
|
1435
|
+
<td class="name"><code>option</code></td>
|
|
1336
1436
|
|
|
1337
1437
|
|
|
1338
1438
|
<td class="type">
|
|
@@ -1365,7 +1465,77 @@
|
|
|
1365
1465
|
</td>
|
|
1366
1466
|
|
|
1367
1467
|
|
|
1368
|
-
<td class="description last"><p
|
|
1468
|
+
<td class="description last"><p>輸入設定物件,預設為{}</p>
|
|
1469
|
+
<h6>Properties</h6>
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
<table class="params">
|
|
1473
|
+
<thead>
|
|
1474
|
+
<tr>
|
|
1475
|
+
|
|
1476
|
+
<th>Name</th>
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
<th>Type</th>
|
|
1480
|
+
|
|
1481
|
+
|
|
1482
|
+
<th>Attributes</th>
|
|
1483
|
+
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
<th>Default</th>
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
<th class="last">Description</th>
|
|
1490
|
+
</tr>
|
|
1491
|
+
</thead>
|
|
1492
|
+
|
|
1493
|
+
<tbody>
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
<tr>
|
|
1497
|
+
|
|
1498
|
+
<td class="name"><code>autoInsert</code></td>
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
<td class="type">
|
|
1502
|
+
|
|
1503
|
+
|
|
1504
|
+
<span class="param-type">boolean</span>
|
|
1505
|
+
|
|
1506
|
+
|
|
1507
|
+
|
|
1508
|
+
|
|
1509
|
+
</td>
|
|
1510
|
+
|
|
1511
|
+
|
|
1512
|
+
<td class="attributes">
|
|
1513
|
+
|
|
1514
|
+
<optional><br>
|
|
1515
|
+
|
|
1516
|
+
|
|
1517
|
+
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
</td>
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
<td class="default">
|
|
1525
|
+
|
|
1526
|
+
<code>true</code>
|
|
1527
|
+
|
|
1528
|
+
</td>
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
<td class="description last"><p>輸入是否於儲存時發現原本無數據,則自動改以插入處理,預設為true</p></td>
|
|
1532
|
+
</tr>
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
</tbody>
|
|
1536
|
+
</table>
|
|
1537
|
+
|
|
1538
|
+
</td>
|
|
1369
1539
|
</tr>
|
|
1370
1540
|
|
|
1371
1541
|
|
|
@@ -1391,7 +1561,7 @@
|
|
|
1391
1561
|
|
|
1392
1562
|
|
|
1393
1563
|
<div class="param-desc">
|
|
1394
|
-
<p>回傳Promise,resolve
|
|
1564
|
+
<p>回傳Promise,resolve回傳與輸入等長之儲存結果陣列,各筆為{n,nInserted,nModified,ok},n為主鍵命中筆數,單筆失敗者ok為0並附err,reject回傳錯誤訊息</p>
|
|
1395
1565
|
</div>
|
|
1396
1566
|
|
|
1397
1567
|
|
|
@@ -1410,6 +1580,437 @@
|
|
|
1410
1580
|
</dl>
|
|
1411
1581
|
|
|
1412
1582
|
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
<h4 class="name" id=".selectByPkCore"><span class="type-signature type-signature-async, static">(async, static) </span>selectByPkCore<span class="signature">(pk)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
1592
|
+
|
|
1593
|
+
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
|
|
1597
|
+
|
|
1598
|
+
<dl class="details">
|
|
1599
|
+
|
|
1600
|
+
<dt class="tag-description">Description:</dt>
|
|
1601
|
+
<dd class="tag-description"><ul class="dummy"><li><p>由主鍵查詢單筆數據
|
|
1602
|
+
註: 本套件之主鍵欄位固定為id,尚未支援指定其他欄位為主鍵
|
|
1603
|
+
註: lowdb無索引,本函數仍須讀取全表,故較select僅省去查詢條件之過濾而無數量級之效能差異,
|
|
1604
|
+
提供本函數係為與其他w-orm系列套件維持同一組函數</p></li></ul></dd>
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
<dt class="tag-source">Source:</dt>
|
|
1609
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
1610
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line323">line 323</a>
|
|
1611
|
+
</li></ul></dd>
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
|
|
1622
|
+
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
</dl>
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
|
|
1653
|
+
|
|
1654
|
+
|
|
1655
|
+
|
|
1656
|
+
|
|
1657
|
+
<h5 class="h5-parameters">Parameters:</h5>
|
|
1658
|
+
|
|
1659
|
+
|
|
1660
|
+
<table class="params">
|
|
1661
|
+
<thead>
|
|
1662
|
+
<tr>
|
|
1663
|
+
|
|
1664
|
+
<th>Name</th>
|
|
1665
|
+
|
|
1666
|
+
|
|
1667
|
+
<th>Type</th>
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
<th class="last">Description</th>
|
|
1674
|
+
</tr>
|
|
1675
|
+
</thead>
|
|
1676
|
+
|
|
1677
|
+
<tbody>
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
<tr>
|
|
1681
|
+
|
|
1682
|
+
<td class="name"><code>pk</code></td>
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
<td class="type">
|
|
1686
|
+
|
|
1687
|
+
|
|
1688
|
+
<span class="param-type">String</span>
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
</td>
|
|
1694
|
+
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
<td class="description last"><p>輸入主鍵值字串,本套件之主鍵欄位為id</p></td>
|
|
1700
|
+
</tr>
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
</tbody>
|
|
1704
|
+
</table>
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1710
|
+
|
|
1711
|
+
|
|
1712
|
+
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
|
|
1718
|
+
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
<h5 class="h5-returns">Returns:</h5>
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
<div class="param-desc">
|
|
1725
|
+
<p>回傳Promise,resolve回傳數據物件,若無此主鍵或主鍵值無效則回傳null,reject回傳錯誤訊息</p>
|
|
1726
|
+
</div>
|
|
1727
|
+
|
|
1728
|
+
|
|
1729
|
+
|
|
1730
|
+
<dl class="param-type">
|
|
1731
|
+
<dt>
|
|
1732
|
+
Type
|
|
1733
|
+
</dt>
|
|
1734
|
+
<dd>
|
|
1735
|
+
|
|
1736
|
+
<span class="param-type">Promise</span>
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
</dd>
|
|
1741
|
+
</dl>
|
|
1742
|
+
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
|
|
1749
|
+
|
|
1750
|
+
|
|
1751
|
+
|
|
1752
|
+
<h4 class="name" id=".selectCore"><span class="type-signature type-signature-async, static">(async, static) </span>selectCore<span class="signature">(find<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
|
|
1753
|
+
|
|
1754
|
+
|
|
1755
|
+
|
|
1756
|
+
|
|
1757
|
+
|
|
1758
|
+
|
|
1759
|
+
<dl class="details">
|
|
1760
|
+
|
|
1761
|
+
<dt class="tag-description">Description:</dt>
|
|
1762
|
+
<dd class="tag-description"><ul class="dummy"><li><p>查詢數據</p></li></ul></dd>
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
|
|
1766
|
+
<dt class="tag-source">Source:</dt>
|
|
1767
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
1768
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line260">line 260</a>
|
|
1769
|
+
</li></ul></dd>
|
|
1770
|
+
|
|
1771
|
+
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
|
|
1778
|
+
|
|
1779
|
+
|
|
1780
|
+
|
|
1781
|
+
|
|
1782
|
+
|
|
1783
|
+
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
|
|
1798
|
+
|
|
1799
|
+
|
|
1800
|
+
|
|
1801
|
+
</dl>
|
|
1802
|
+
|
|
1803
|
+
|
|
1804
|
+
|
|
1805
|
+
|
|
1806
|
+
|
|
1807
|
+
|
|
1808
|
+
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
|
|
1812
|
+
|
|
1813
|
+
|
|
1814
|
+
|
|
1815
|
+
<h5 class="h5-parameters">Parameters:</h5>
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
<table class="params">
|
|
1819
|
+
<thead>
|
|
1820
|
+
<tr>
|
|
1821
|
+
|
|
1822
|
+
<th>Name</th>
|
|
1823
|
+
|
|
1824
|
+
|
|
1825
|
+
<th>Type</th>
|
|
1826
|
+
|
|
1827
|
+
|
|
1828
|
+
<th>Attributes</th>
|
|
1829
|
+
|
|
1830
|
+
|
|
1831
|
+
|
|
1832
|
+
<th>Default</th>
|
|
1833
|
+
|
|
1834
|
+
|
|
1835
|
+
<th class="last">Description</th>
|
|
1836
|
+
</tr>
|
|
1837
|
+
</thead>
|
|
1838
|
+
|
|
1839
|
+
<tbody>
|
|
1840
|
+
|
|
1841
|
+
|
|
1842
|
+
<tr>
|
|
1843
|
+
|
|
1844
|
+
<td class="name"><code>find</code></td>
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
<td class="type">
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
<span class="param-type">Object</span>
|
|
1851
|
+
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
</td>
|
|
1856
|
+
|
|
1857
|
+
|
|
1858
|
+
<td class="attributes">
|
|
1859
|
+
|
|
1860
|
+
<optional><br>
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
|
|
1865
|
+
|
|
1866
|
+
</td>
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
|
|
1870
|
+
<td class="default">
|
|
1871
|
+
|
|
1872
|
+
<code>{}</code>
|
|
1873
|
+
|
|
1874
|
+
</td>
|
|
1875
|
+
|
|
1876
|
+
|
|
1877
|
+
<td class="description last"><p>輸入查詢條件物件</p></td>
|
|
1878
|
+
</tr>
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
</tbody>
|
|
1882
|
+
</table>
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
<h5 class="h5-returns">Returns:</h5>
|
|
1900
|
+
|
|
1901
|
+
|
|
1902
|
+
<div class="param-desc">
|
|
1903
|
+
<p>回傳Promise,resolve回傳數據陣列,無符合數據回傳空陣列,reject回傳錯誤訊息</p>
|
|
1904
|
+
</div>
|
|
1905
|
+
|
|
1906
|
+
|
|
1907
|
+
|
|
1908
|
+
<dl class="param-type">
|
|
1909
|
+
<dt>
|
|
1910
|
+
Type
|
|
1911
|
+
</dt>
|
|
1912
|
+
<dd>
|
|
1913
|
+
|
|
1914
|
+
<span class="param-type">Promise</span>
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
|
|
1918
|
+
</dd>
|
|
1919
|
+
</dl>
|
|
1920
|
+
|
|
1921
|
+
|
|
1922
|
+
|
|
1923
|
+
|
|
1924
|
+
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
<h4 class="name" id="~serialize"><span class="type-signature type-signature-inner">(inner) </span>serialize<span class="signature">()</span><span class="type-signature"></span></h4>
|
|
1931
|
+
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
<dl class="details">
|
|
1938
|
+
|
|
1939
|
+
<dt class="tag-description">Description:</dt>
|
|
1940
|
+
<dd class="tag-description"><ul class="dummy"><li><p>序列化同一資料庫檔案之操作</p>
|
|
1941
|
+
<p>本套件之寫入為[整檔讀出、記憶體修改、整檔寫回],lowdb無條件寫入亦無比較並交換,
|
|
1942
|
+
故insert之[檢查主鍵不存在與寫入]與save之[查找主鍵與更新或插入],其原子性只能由行程內之序列化達成。
|
|
1943
|
+
採Promise鏈而非[布林旗標配合輪詢等待],係因後者之[檢查旗標]與[設定旗標]之間隔有await,
|
|
1944
|
+
並非原子之test-and-set,多個等候者之輪詢若落在同一批timer觸發即會同時進入臨界區;
|
|
1945
|
+
且輪詢函數逾時後為resolve而非reject,等滿即照樣放行。Promise鏈為嚴格FIFO且無逾時放行,由結構保證互斥。
|
|
1946
|
+
select亦納入序列化,令其不致與寫入之整檔替換交錯。</p>
|
|
1947
|
+
<p>註: 佇列為module層之變數,僅同一行程內共享,故跨行程併發不受此保護。</p></li></ul></dd>
|
|
1948
|
+
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
<dt class="tag-source">Source:</dt>
|
|
1952
|
+
<dd class="tag-source"><ul class="dummy"><li>
|
|
1953
|
+
<a href="WOrmLowdb.mjs.html">WOrmLowdb.mjs</a>, <a href="WOrmLowdb.mjs.html#line129">line 129</a>
|
|
1954
|
+
</li></ul></dd>
|
|
1955
|
+
|
|
1956
|
+
|
|
1957
|
+
|
|
1958
|
+
|
|
1959
|
+
|
|
1960
|
+
|
|
1961
|
+
|
|
1962
|
+
|
|
1963
|
+
|
|
1964
|
+
|
|
1965
|
+
|
|
1966
|
+
|
|
1967
|
+
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
|
|
1980
|
+
|
|
1981
|
+
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
|
|
1985
|
+
|
|
1986
|
+
</dl>
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
|
|
1993
|
+
|
|
1994
|
+
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
|
|
1998
|
+
|
|
1999
|
+
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
|
|
2006
|
+
|
|
2007
|
+
|
|
2008
|
+
|
|
2009
|
+
|
|
2010
|
+
|
|
2011
|
+
|
|
2012
|
+
|
|
2013
|
+
|
|
1413
2014
|
|
|
1414
2015
|
|
|
1415
2016
|
|
|
@@ -1433,7 +2034,7 @@
|
|
|
1433
2034
|
<br class="clear">
|
|
1434
2035
|
|
|
1435
2036
|
<footer>
|
|
1436
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on
|
|
2037
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Aug 17 2026 20:57:08 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1437
2038
|
</footer>
|
|
1438
2039
|
|
|
1439
2040
|
<script>prettyPrint();</script>
|