w-orm-lmdb 1.0.5 → 1.0.7

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.
@@ -80,7 +80,7 @@
80
80
 
81
81
  <dt class="tag-source">Source:</dt>
82
82
  <dd class="tag-source"><ul class="dummy"><li>
83
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line32">line 32</a>
83
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line34">line 34</a>
84
84
  </li></ul></dd>
85
85
 
86
86
 
@@ -336,6 +336,46 @@
336
336
  </tr>
337
337
 
338
338
 
339
+
340
+ <tr>
341
+
342
+ <td class="name"><code>useCache</code></td>
343
+
344
+
345
+ <td class="type">
346
+
347
+
348
+ <span class="param-type">Boolean</span>
349
+
350
+
351
+
352
+
353
+ </td>
354
+
355
+
356
+ <td class="attributes">
357
+
358
+ &lt;optional><br>
359
+
360
+
361
+
362
+
363
+
364
+ </td>
365
+
366
+
367
+
368
+ <td class="default">
369
+
370
+ <code>false</code>
371
+
372
+ </td>
373
+
374
+
375
+ <td class="description last"><p>輸入是否使用select快取,適用於單程序操作,預設false</p></td>
376
+ </tr>
377
+
378
+
339
379
  </tbody>
340
380
  </table>
341
381
 
@@ -429,7 +469,7 @@
429
469
 
430
470
  <dt class="tag-source">Source:</dt>
431
471
  <dd class="tag-source"><ul class="dummy"><li>
432
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line407">line 407</a>
472
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line416">line 416</a>
433
473
  </li></ul></dd>
434
474
 
435
475
 
@@ -590,7 +630,7 @@
590
630
 
591
631
  <dt class="tag-source">Source:</dt>
592
632
  <dd class="tag-source"><ul class="dummy"><li>
593
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line522">line 522</a>
633
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line531">line 531</a>
594
634
  </li></ul></dd>
595
635
 
596
636
 
@@ -768,7 +808,7 @@
768
808
 
769
809
  <dt class="tag-source">Source:</dt>
770
810
  <dd class="tag-source"><ul class="dummy"><li>
771
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line177">line 177</a>
811
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line186">line 186</a>
772
812
  </li></ul></dd>
773
813
 
774
814
 
@@ -929,7 +969,7 @@
929
969
 
930
970
  <dt class="tag-source">Source:</dt>
931
971
  <dd class="tag-source"><ul class="dummy"><li>
932
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line280">line 280</a>
972
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line289">line 289</a>
933
973
  </li></ul></dd>
934
974
 
935
975
 
@@ -1216,7 +1256,7 @@
1216
1256
 
1217
1257
  <dt class="tag-source">Source:</dt>
1218
1258
  <dd class="tag-source"><ul class="dummy"><li>
1219
- <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line123">line 123</a>
1259
+ <a href="WOrmLmdb.mjs.html">WOrmLmdb.mjs</a>, <a href="WOrmLmdb.mjs.html#line132">line 132</a>
1220
1260
  </li></ul></dd>
1221
1261
 
1222
1262
 
@@ -1393,7 +1433,7 @@
1393
1433
  <br class="clear">
1394
1434
 
1395
1435
  <footer>
1396
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu May 14 2026 19:53:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1436
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Jun 30 2026 10:11:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1397
1437
  </footer>
1398
1438
 
1399
1439
  <script>prettyPrint();</script>
@@ -59,6 +59,7 @@ import isestr from 'wsemi/src/isestr.mjs'
59
59
  import isarr from 'wsemi/src/isarr.mjs'
60
60
  import isearr from 'wsemi/src/isearr.mjs'
61
61
  import iseobj from 'wsemi/src/iseobj.mjs'
62
+ import isbol from 'wsemi/src/isbol.mjs'
62
63
  import haskey from 'wsemi/src/haskey.mjs'
63
64
  import evem from 'wsemi/src/evem.mjs'
64
65
  import genIDSeq from 'wsemi/src/genIDSeq.mjs'
@@ -74,6 +75,7 @@ import waitFun from 'wsemi/src/waitFun.mjs'
74
75
  * @param {String} [opt.url='_db'] 輸入資料庫用資料夾字串,預設'_db'
75
76
  * @param {String} [opt.db='worm'] 輸入使用資料庫名稱字串,預設'worm'
76
77
  * @param {String} [opt.cl='test'] 輸入使用資料表名稱字串,預設'test'
78
+ * @param {Boolean} [opt.useCache=false] 輸入是否使用select快取,適用於單程序操作,預設false
77
79
  * @returns {Object} 回傳操作資料庫物件,各事件功能詳見說明
78
80
  */
79
81
  function WOrmLmdb(opt = {}) {
@@ -99,6 +101,12 @@ function WOrmLmdb(opt = {}) {
99
101
  cl = 'test'
100
102
  }
101
103
 
104
+ //useCache
105
+ let useCache = get(opt, 'useCache')
106
+ if (!isbol(useCache)) {
107
+ useCache = false
108
+ }
109
+
102
110
  //storage
103
111
  let storage = `${url}/${db}/${cl}`
104
112
  // console.log('storage',storage)
@@ -117,7 +125,7 @@ function WOrmLmdb(opt = {}) {
117
125
  let getData = async() => {
118
126
 
119
127
  //check
120
- if (isarr(_cache)) {
128
+ if (useCache &amp;&amp; isarr(_cache)) {
121
129
  return cloneDeep(_cache) //與外部使用數據脫勾
122
130
  }
123
131
 
@@ -137,10 +145,11 @@ function WOrmLmdb(opt = {}) {
137
145
  ltdt.push(dt)
138
146
  }
139
147
 
140
- //update
141
- _cache = ltdt
142
-
143
- return cloneDeep(ltdt) //與外部使用數據脫勾
148
+ if (useCache) {
149
+ _cache = ltdt
150
+ return cloneDeep(ltdt) //與外部使用數據脫勾
151
+ }
152
+ return ltdt
144
153
  }
145
154
 
146
155
  //getValue
@@ -673,12 +682,20 @@ function WOrmLmdb(opt = {}) {
673
682
  return res
674
683
  }
675
684
 
685
+ //close, 關閉內部LMDB env並釋放檔案鎖, close後該實例即報廢, 須重新new WOrmLmdb
686
+ let close = async () => {
687
+ if (client &amp;&amp; client.status !== 'closed') {
688
+ await client.close() //lmdb root database之close(), 回傳Promise
689
+ }
690
+ }
691
+
676
692
  //save
677
693
  ee.select = select
678
694
  ee.insert = insert
679
695
  ee.save = save
680
696
  ee.del = del
681
697
  ee.delAll = delAll
698
+ ee.close = close
682
699
 
683
700
  return ee
684
701
  }
@@ -699,7 +716,7 @@ export default WOrmLmdb
699
716
  <br class="clear">
700
717
 
701
718
  <footer>
702
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Thu May 14 2026 19:53:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
719
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Jun 30 2026 10:11:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
703
720
  </footer>
704
721
 
705
722
  <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 Thu May 14 2026 19:53:45 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Tue Jun 30 2026 10:11:04 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
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "w-orm-lmdb",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "main": "dist/w-orm-lmdb.umd.js",
5
5
  "dependencies": {
6
6
  "lodash-es": "^4.18.1",
7
- "lmdb": "^3.5.4",
8
- "mingo": "^7.2.1",
9
- "wsemi": "^1.8.52"
7
+ "lmdb": "^3.5.6",
8
+ "mingo": "^7.2.2",
9
+ "wsemi": "^1.8.62"
10
10
  },
11
11
  "devDependencies": {
12
- "w-package-tools": "^1.1.5"
12
+ "w-package-tools": "^1.1.9"
13
13
  },
14
14
  "scripts": {
15
15
  "test": "mocha --parallel --timeout 60000",
package/src/WOrmLmdb.mjs CHANGED
@@ -12,6 +12,7 @@ import isestr from 'wsemi/src/isestr.mjs'
12
12
  import isarr from 'wsemi/src/isarr.mjs'
13
13
  import isearr from 'wsemi/src/isearr.mjs'
14
14
  import iseobj from 'wsemi/src/iseobj.mjs'
15
+ import isbol from 'wsemi/src/isbol.mjs'
15
16
  import haskey from 'wsemi/src/haskey.mjs'
16
17
  import evem from 'wsemi/src/evem.mjs'
17
18
  import genIDSeq from 'wsemi/src/genIDSeq.mjs'
@@ -27,6 +28,7 @@ import waitFun from 'wsemi/src/waitFun.mjs'
27
28
  * @param {String} [opt.url='_db'] 輸入資料庫用資料夾字串,預設'_db'
28
29
  * @param {String} [opt.db='worm'] 輸入使用資料庫名稱字串,預設'worm'
29
30
  * @param {String} [opt.cl='test'] 輸入使用資料表名稱字串,預設'test'
31
+ * @param {Boolean} [opt.useCache=false] 輸入是否使用select快取,適用於單程序操作,預設false
30
32
  * @returns {Object} 回傳操作資料庫物件,各事件功能詳見說明
31
33
  */
32
34
  function WOrmLmdb(opt = {}) {
@@ -52,6 +54,12 @@ function WOrmLmdb(opt = {}) {
52
54
  cl = 'test'
53
55
  }
54
56
 
57
+ //useCache
58
+ let useCache = get(opt, 'useCache')
59
+ if (!isbol(useCache)) {
60
+ useCache = false
61
+ }
62
+
55
63
  //storage
56
64
  let storage = `${url}/${db}/${cl}`
57
65
  // console.log('storage',storage)
@@ -70,7 +78,7 @@ function WOrmLmdb(opt = {}) {
70
78
  let getData = async() => {
71
79
 
72
80
  //check
73
- if (isarr(_cache)) {
81
+ if (useCache && isarr(_cache)) {
74
82
  return cloneDeep(_cache) //與外部使用數據脫勾
75
83
  }
76
84
 
@@ -90,10 +98,11 @@ function WOrmLmdb(opt = {}) {
90
98
  ltdt.push(dt)
91
99
  }
92
100
 
93
- //update
94
- _cache = ltdt
95
-
96
- return cloneDeep(ltdt) //與外部使用數據脫勾
101
+ if (useCache) {
102
+ _cache = ltdt
103
+ return cloneDeep(ltdt) //與外部使用數據脫勾
104
+ }
105
+ return ltdt
97
106
  }
98
107
 
99
108
  //getValue
@@ -626,12 +635,20 @@ function WOrmLmdb(opt = {}) {
626
635
  return res
627
636
  }
628
637
 
638
+ //close, 關閉內部LMDB env並釋放檔案鎖, close後該實例即報廢, 須重新new WOrmLmdb
639
+ let close = async () => {
640
+ if (client && client.status !== 'closed') {
641
+ await client.close() //lmdb root database之close(), 回傳Promise
642
+ }
643
+ }
644
+
629
645
  //save
630
646
  ee.select = select
631
647
  ee.insert = insert
632
648
  ee.save = save
633
649
  ee.del = del
634
650
  ee.delAll = delAll
651
+ ee.close = close
635
652
 
636
653
  return ee
637
654
  }