w-orm-lmdb 1.0.4 → 1.0.6

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.
@@ -4,392 +4,418 @@ import w from 'wsemi'
4
4
  import WOrm from '../src/WOrmLmdb.mjs'
5
5
 
6
6
 
7
- function isWindows() {
8
- return process.platform === 'win32'
9
- }
10
-
11
- if (isWindows()) {
12
- describe('basic', function() {
13
- let rt = null
14
- let vans = {}
15
- let vget = {}
16
-
17
- before(async function () {
18
-
19
- w.fsDeleteFolder('./_db')
20
-
21
- let opt = {
22
- url: './_db',
23
- db: 'worm',
24
- cl: 'users',
25
- }
26
-
27
- let rs = [
28
- {
29
- id: 'id-peter',
30
- name: 'peter',
31
- value: 123,
32
- },
33
- {
34
- id: 'id-rosemary',
35
- name: 'rosemary',
36
- value: 123.456,
37
- },
38
- {
39
- id: '',
40
- name: 'kettle',
41
- value: 456,
42
- },
43
- ]
44
-
45
- let rsm = [
46
- {
47
- id: 'id-peter',
48
- name: 'peter(modify)'
49
- },
50
- {
51
- id: 'id-rosemary',
52
- name: 'rosemary(modify)'
53
- },
54
- {
55
- id: '',
56
- name: 'kettle(modify)'
57
- },
58
- ]
59
-
60
- //wo
61
- let wo = WOrm(opt)
62
-
63
- //on
64
- wo.on('change', function(mode, data, res) {
65
- // console.log('change', mode)
66
- })
7
+ describe('basic', function() {
8
+ let rt = null
9
+ let vans = {}
10
+ let vget = {}
67
11
 
68
- //delAll
69
- rt = null
70
- // vans[1] = {
71
- // nDeleted: 0,
72
- // ok: 1,
73
- // }
74
- await wo.delAll()
75
- .then(function(msg) {
76
- // console.log('delAll then', msg)
77
- //考慮可能有不同初始測試數據
78
- // delAll then { n: 2, nDeleted: 2, ok: 1 }
79
- // delAll then { n: 3, nDeleted: 2, ok: 1 }
80
- //僅針對nDeleted與ok欄位比對
81
- rt = {
82
- nDeleted: msg.nDeleted,
83
- ok: msg.ok,
84
- }
85
- })
86
- .catch(function(msg) {
87
- // console.log('delAll catch', msg)
88
- rt = msg.toString()
89
- })
90
- vget[1] = rt
91
-
92
- //insert
93
- rt = null
94
- // vans[2] = { n: 3, nInserted: 3, ok: 1 }
95
- await wo.insert(rs)
96
- .then(function(msg) {
97
- // console.log('insert then', msg)
98
- // insert then { n: 3, nInserted: 3, ok: 1 }
99
- rt = msg
100
- })
101
- .catch(function(msg) {
102
- // console.log('insert catch', msg)
103
- rt = msg.toString()
104
- })
105
- vget[2] = rt
106
-
107
- //save
108
- rt = null
109
- // vans[3] = [
110
- // { n: 1, nModified: 1, ok: 1 },
111
- // { n: 1, nModified: 1, ok: 1 },
112
- // { n: 0, nModified: 0, ok: 1 }
113
- // ]
114
- await wo.save(rsm, { autoInsert: false })
115
- .then(function(msg) {
116
- // console.log('save then', msg)
117
- // save then [
118
- // { n: 1, nModified: 1, ok: 1 },
119
- // { n: 1, nModified: 1, ok: 1 },
120
- // { n: 0, nModified: 0, ok: 1 }
121
- // ]
122
- rt = msg
123
- })
124
- .catch(function(msg) {
125
- // console.log('save catch', msg)
126
- rt = msg.toString()
127
- })
128
- vget[3] = rt
129
-
130
- //select all
131
- rt = null
132
- // vans[4] = [
133
- // {
134
- // // id: {random id},
135
- // name: 'kettle',
136
- // value: 456
137
- // },
138
- // { id: 'id-peter', name: 'peter(modify)', value: 123 },
139
- // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
140
- // ]
141
- await wo.select()
142
- .then(function(msg) {
143
- // console.log('select all then', msg)
144
- msg = _.sortBy(msg, 'name')
145
- // select all [
146
- // {
147
- // id: {random id},
148
- // name: 'kettle',
149
- // value: 456
150
- // },
151
- // { id: 'id-peter', name: 'peter(modify)', value: 123 },
152
- // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }
153
- // ]
154
- rt = [
155
- {
156
- name: msg[0].name,
157
- value: msg[0].value,
158
- },
159
- msg[1],
160
- msg[2],
161
- ]
162
- })
163
- .catch(function(msg) {
164
- // console.log('select all catch', msg)
165
- rt = msg.toString()
166
- })
167
- vget[4] = rt
168
-
169
- //select
170
- rt = null
171
- // vans[5] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
172
- await wo.select({ id: 'id-rosemary' })
173
- .then(function(msg) {
174
- // console.log('select then', msg)
175
- // select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
176
- rt = msg
177
- })
178
- .catch(function(msg) {
179
- // console.log('select catch', msg)
180
- rt = msg.toString()
181
- })
182
- vget[5] = rt
183
-
184
- //select by $and, $gt, $lt
185
- rt = null
186
- // vans[6] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
187
- await wo.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
188
- .then(function(msg) {
189
- // console.log('select by $and, $gt, $lt then', msg)
190
- // select by $and, $gt, $lt [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
191
- rt = msg
192
- })
193
- .catch(function(msg) {
194
- // console.log('select by $and, $gt, $lt catch', msg)
195
- rt = msg.toString()
196
- })
197
- vget[6] = rt
198
-
199
- //select by $or, $gte, $lte
200
- rt = null
201
- // vans[7] = [
202
- // {
203
- // // id: {random id},
204
- // name: 'kettle',
205
- // value: 456
206
- // }
207
- // ]
208
- await wo.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
209
- .then(function(msg) {
210
- // console.log('select by $or, $gte, $lte then', msg)
211
- // select by $or, $gte, $lte [
212
- // {
213
- // id: {random id},
214
- // name: 'kettle',
215
- // value: 456
216
- // }
217
- // ]
218
- rt = [
219
- {
220
- name: msg[0].name,
221
- value: msg[0].value,
222
- },
223
- ]
224
- })
225
- .catch(function(msg) {
226
- // console.log('select by $or, $gte, $lte catch', msg)
227
- rt = msg.toString()
228
- })
229
- vget[7] = rt
230
-
231
- //select by $or, $and, $ne, $in, $nin
232
- rt = null
233
- // vans[8] = [
234
- // {
235
- // id: 'id-rosemary',
236
- // name: 'rosemary(modify)',
237
- // value: 123.456
238
- // },
239
- // {
240
- // // id: {random id},
241
- // name: 'kettle',
242
- // value: 456
243
- // }
244
- // ]
245
- await wo.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
246
- .then(function(msg) {
247
- // console.log('select by $or, $and, $ne, $in, $nin then', msg)
248
- msg = _.sortBy(msg, 'name')
249
- // select by $or, $and, $ne, $in, $nin [
250
- // {
251
- // id: 'id-rosemary',
252
- // name: 'rosemary(modify)',
253
- // value: 123.456
254
- // },
255
- // {
256
- // id: {random id},
257
- // name: 'kettle',
258
- // value: 456
259
- // }
260
- // ]
261
- rt = [
262
- {
263
- name: msg[0].name,
264
- value: msg[0].value,
265
- },
266
- msg[1],
267
- ]
268
- })
269
- .catch(function(msg) {
270
- // console.log('select by $or, $and, $ne, $in, $nin catch', msg)
271
- rt = msg.toString()
272
- })
273
- vget[8] = rt
274
-
275
- // //select by regex
276
- // rt = null
277
- // vans[9] = [{ id: 'id-peter', name: 'peter(modify)', value: 123 }]
278
- // await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
279
- // .then(function(msg) {
280
- // // console.log('select by regex then', msg)
281
- // // selectReg [ { id: 'id-peter', name: 'peter(modify)', value: 123 } ]
282
- // rt = msg
283
- // })
284
- // .catch(function(msg) {
285
- // // console.log('select by regex catch', msg)
286
- // rt = msg.toString()
287
- // })
288
- // vget[9] = rt
289
-
290
- //del
291
- rt = null
292
- // vans[10] = [{ n: 1, nDeleted: 1, ok: 1 }]
293
- let ss = await wo.select()
294
- let d = ss.filter(function(v) {
295
- return v.name === 'kettle'
296
- })
297
- await wo.del(d)
298
- .then(function(msg) {
299
- // console.log('del then', msg)
300
- // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
301
- rt = msg
302
- })
303
- .catch(function(msg) {
304
- // console.log('del catch', msg)
305
- rt = msg.toString()
306
- })
307
- vget[10] = rt
12
+ before(async function () {
308
13
 
309
- })
14
+ w.fsDeleteFolder('./_db')
310
15
 
311
- vans[1] = {
312
- nDeleted: 0,
313
- ok: 1,
16
+ let opt = {
17
+ url: './_db',
18
+ db: 'worm',
19
+ cl: 'users',
314
20
  }
315
- it(`should get ${JSON.stringify(vans[1])} for delAll`, async function() {
316
- assert.strict.deepStrictEqual(vget[1], vans[1])
317
- })
318
-
319
- vans[2] = { n: 3, nInserted: 3, ok: 1 }
320
- it(`should get ${JSON.stringify(vans[2])} for insert`, async function() {
321
- assert.strict.deepStrictEqual(vget[2], vans[2])
322
- })
323
21
 
324
- vans[3] = [
325
- { n: 1, nModified: 1, ok: 1 },
326
- { n: 1, nModified: 1, ok: 1 },
327
- { n: 0, nModified: 0, ok: 1 }
328
- ]
329
- it(`should get ${JSON.stringify(vans[3])} for save`, async function() {
330
- assert.strict.deepStrictEqual(vget[3], vans[3])
331
- })
332
-
333
- vans[4] = [
22
+ let rs = [
334
23
  {
335
- // id: {random id},
336
- name: 'kettle',
337
- value: 456
24
+ id: 'id-peter',
25
+ name: 'peter',
26
+ value: 123,
27
+ },
28
+ {
29
+ id: 'id-rosemary',
30
+ name: 'rosemary',
31
+ value: 123.456,
338
32
  },
339
- { id: 'id-peter', name: 'peter(modify)', value: 123 },
340
- { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
341
- ]
342
- it(`should get ${JSON.stringify(vans[4])} for select all`, async function() {
343
- assert.strict.deepStrictEqual(vget[4], vans[4])
344
- })
345
-
346
- vans[5] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
347
- it(`should get ${JSON.stringify(vans[5])} for select`, async function() {
348
- assert.strict.deepStrictEqual(vget[5], vans[5])
349
- })
350
-
351
- vans[6] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
352
- it(`should get ${JSON.stringify(vans[6])} for select by $and, $gt, $lt`, async function() {
353
- assert.strict.deepStrictEqual(vget[6], vans[6])
354
- })
355
-
356
- vans[7] = [
357
33
  {
358
- // id: {random id},
34
+ id: '',
359
35
  name: 'kettle',
360
- value: 456
361
- }
36
+ value: 456,
37
+ },
362
38
  ]
363
- it(`should get ${JSON.stringify(vans[7])} for select by $or, $gte, $lte`, async function() {
364
- assert.strict.deepStrictEqual(vget[7], vans[7])
365
- })
366
39
 
367
- vans[8] = [
40
+ let rsm = [
368
41
  {
369
- // id: {random id},
370
- name: 'kettle',
371
- value: 456
42
+ id: 'id-peter',
43
+ name: 'peter(modify)'
44
+ },
45
+ {
46
+ id: 'id-rosemary',
47
+ name: 'rosemary(modify)'
48
+ },
49
+ {
50
+ id: '',
51
+ name: 'kettle(modify)'
372
52
  },
53
+ ]
54
+
55
+ let rsa = [
373
56
  {
374
57
  id: 'id-rosemary',
375
- name: 'rosemary(modify)',
376
- value: 123.456
377
- }
58
+ name: 'rosemary',
59
+ value: 654.321,
60
+ },
378
61
  ]
379
- it(`should get ${JSON.stringify(vans[8])} for select by $or, $and, $ne, $in, $nin`, async function() {
380
- assert.strict.deepStrictEqual(vget[8], vans[8])
62
+
63
+ //wo
64
+ let wo = WOrm(opt)
65
+
66
+ //on
67
+ wo.on('change', function(mode, data, res) {
68
+ // console.log('change', mode)
381
69
  })
382
70
 
383
- // vans[9] = [{ id: 'id-peter', name: 'peter(modify)', value: 123 }]
384
- // it(`should get ${JSON.stringify(vans[9])} for select by regex`, async function() {
385
- // assert.strict.deepStrictEqual(vget[9], vans[9])
386
- // })
71
+ //delAll
72
+ rt = null
73
+ // vans[1] = {
74
+ // nDeleted: 0,
75
+ // ok: 1,
76
+ // }
77
+ await wo.delAll()
78
+ .then(function(msg) {
79
+ // console.log('delAll then', msg)
80
+ //考慮可能有不同初始測試數據
81
+ // delAll then { n: 2, nDeleted: 2, ok: 1 }
82
+ // delAll then { n: 3, nDeleted: 2, ok: 1 }
83
+ //僅針對nDeleted與ok欄位比對
84
+ rt = {
85
+ nDeleted: msg.nDeleted,
86
+ ok: msg.ok,
87
+ }
88
+ })
89
+ .catch(function(msg) {
90
+ // console.log('delAll catch', msg)
91
+ rt = msg.toString()
92
+ })
93
+ vget[1] = rt
94
+
95
+ //insert
96
+ rt = null
97
+ // vans[2] = { n: 3, nInserted: 3, ok: 1 }
98
+ await wo.insert(rs)
99
+ .then(function(msg) {
100
+ // console.log('insert then', msg)
101
+ // insert then { n: 3, nInserted: 3, ok: 1 }
102
+ rt = msg
103
+ })
104
+ .catch(function(msg) {
105
+ // console.log('insert catch', msg)
106
+ rt = msg.toString()
107
+ })
108
+ vget[2] = rt
109
+
110
+ //save
111
+ rt = null
112
+ // vans[3] = [
113
+ // { n: 1, nModified: 1, ok: 1 },
114
+ // { n: 1, nModified: 1, ok: 1 },
115
+ // { n: 0, nModified: 0, ok: 1 }
116
+ // ]
117
+ await wo.save(rsm, { autoInsert: false })
118
+ .then(function(msg) {
119
+ // console.log('save then', msg)
120
+ // save then [
121
+ // { n: 1, nModified: 1, ok: 1 },
122
+ // { n: 1, nModified: 1, ok: 1 },
123
+ // { n: 0, nModified: 0, ok: 1 }
124
+ // ]
125
+ rt = msg
126
+ })
127
+ .catch(function(msg) {
128
+ // console.log('save catch', msg)
129
+ rt = msg.toString()
130
+ })
131
+ vget[3] = rt
132
+
133
+ //select all
134
+ rt = null
135
+ // vans[4] = [
136
+ // {
137
+ // // id: {random id},
138
+ // name: 'kettle',
139
+ // value: 456
140
+ // },
141
+ // { id: 'id-peter', name: 'peter(modify)', value: 123 },
142
+ // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
143
+ // ]
144
+ await wo.select()
145
+ .then(function(msg) {
146
+ // console.log('select all then', msg)
147
+ msg = _.sortBy(msg, 'name')
148
+ // select all [
149
+ // {
150
+ // id: {random id},
151
+ // name: 'kettle',
152
+ // value: 456
153
+ // },
154
+ // { id: 'id-peter', name: 'peter(modify)', value: 123 },
155
+ // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }
156
+ // ]
157
+ rt = [
158
+ {
159
+ name: msg[0].name,
160
+ value: msg[0].value,
161
+ },
162
+ msg[1],
163
+ msg[2],
164
+ ]
165
+ })
166
+ .catch(function(msg) {
167
+ // console.log('select all catch', msg)
168
+ rt = msg.toString()
169
+ })
170
+ vget[4] = rt
171
+
172
+ //select
173
+ rt = null
174
+ // vans[5] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
175
+ await wo.select({ id: 'id-rosemary' })
176
+ .then(function(msg) {
177
+ // console.log('select then', msg)
178
+ // select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
179
+ rt = msg
180
+ })
181
+ .catch(function(msg) {
182
+ // console.log('select catch', msg)
183
+ rt = msg.toString()
184
+ })
185
+ vget[5] = rt
186
+
187
+ //select by $and, $gt, $lt
188
+ rt = null
189
+ // vans[6] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
190
+ await wo.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
191
+ .then(function(msg) {
192
+ // console.log('select by $and, $gt, $lt then', msg)
193
+ // select by $and, $gt, $lt [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
194
+ rt = msg
195
+ })
196
+ .catch(function(msg) {
197
+ // console.log('select by $and, $gt, $lt catch', msg)
198
+ rt = msg.toString()
199
+ })
200
+ vget[6] = rt
201
+
202
+ //select by $or, $gte, $lte
203
+ rt = null
204
+ // vans[7] = [
205
+ // {
206
+ // // id: {random id},
207
+ // name: 'kettle',
208
+ // value: 456
209
+ // }
210
+ // ]
211
+ await wo.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
212
+ .then(function(msg) {
213
+ // console.log('select by $or, $gte, $lte then', msg)
214
+ // select by $or, $gte, $lte [
215
+ // {
216
+ // id: {random id},
217
+ // name: 'kettle',
218
+ // value: 456
219
+ // }
220
+ // ]
221
+ rt = [
222
+ {
223
+ name: msg[0].name,
224
+ value: msg[0].value,
225
+ },
226
+ ]
227
+ })
228
+ .catch(function(msg) {
229
+ // console.log('select by $or, $gte, $lte catch', msg)
230
+ rt = msg.toString()
231
+ })
232
+ vget[7] = rt
233
+
234
+ //select by $or, $and, $ne, $in, $nin
235
+ rt = null
236
+ // vans[8] = [
237
+ // {
238
+ // id: 'id-rosemary',
239
+ // name: 'rosemary(modify)',
240
+ // value: 123.456
241
+ // },
242
+ // {
243
+ // // id: {random id},
244
+ // name: 'kettle',
245
+ // value: 456
246
+ // }
247
+ // ]
248
+ await wo.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
249
+ .then(function(msg) {
250
+ // console.log('select by $or, $and, $ne, $in, $nin then', msg)
251
+ msg = _.sortBy(msg, 'name')
252
+ // select by $or, $and, $ne, $in, $nin [
253
+ // {
254
+ // id: 'id-rosemary',
255
+ // name: 'rosemary(modify)',
256
+ // value: 123.456
257
+ // },
258
+ // {
259
+ // id: {random id},
260
+ // name: 'kettle',
261
+ // value: 456
262
+ // }
263
+ // ]
264
+ rt = [
265
+ {
266
+ name: msg[0].name,
267
+ value: msg[0].value,
268
+ },
269
+ msg[1],
270
+ ]
271
+ })
272
+ .catch(function(msg) {
273
+ // console.log('select by $or, $and, $ne, $in, $nin catch', msg)
274
+ rt = msg.toString()
275
+ })
276
+ vget[8] = rt
387
277
 
388
- vans[10] = [{ n: 1, nDeleted: 1, ok: 1 }]
389
- it(`should get ${JSON.stringify(vans[10])} for del`, async function() {
390
- assert.strict.deepStrictEqual(vget[10], vans[10])
278
+ // //select by regex
279
+ // rt = null
280
+ // vans[9] = [{ id: 'id-peter', name: 'peter(modify)', value: 123 }]
281
+ // await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
282
+ // .then(function(msg) {
283
+ // // console.log('select by regex then', msg)
284
+ // // selectReg [ { id: 'id-peter', name: 'peter(modify)', value: 123 } ]
285
+ // rt = msg
286
+ // })
287
+ // .catch(function(msg) {
288
+ // // console.log('select by regex catch', msg)
289
+ // rt = msg.toString()
290
+ // })
291
+ // vget[9] = rt
292
+
293
+ //save
294
+ rt = null
295
+ // vans[10] = [ { n: 1, nModified: 1, ok: 1 } ]
296
+ await wo.save(rsa, { autoInsert: true })
297
+ .then(function(msg) {
298
+ // console.log('save then', msg)
299
+ // save then [
300
+ // { n: 1, nModified: 1, ok: 1 },
301
+ // { n: 1, nModified: 1, ok: 1 },
302
+ // { n: 0, nModified: 0, ok: 1 }
303
+ // ]
304
+ rt = msg
305
+ })
306
+ .catch(function(msg) {
307
+ // console.log('save catch', msg)
308
+ rt = msg.toString()
309
+ })
310
+ vget[10] = rt
311
+
312
+ //del
313
+ rt = null
314
+ // vans[11] = [{ n: 1, nDeleted: 1, ok: 1 }]
315
+ let ss = await wo.select()
316
+ let d = ss.filter(function(v) {
317
+ return v.name === 'kettle'
391
318
  })
319
+ await wo.del(d)
320
+ .then(function(msg) {
321
+ // console.log('del then', msg)
322
+ // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
323
+ rt = msg
324
+ })
325
+ .catch(function(msg) {
326
+ // console.log('del catch', msg)
327
+ rt = msg.toString()
328
+ })
329
+ vget[11] = rt
392
330
 
393
331
  })
394
- }
332
+
333
+ vans[1] = {
334
+ nDeleted: 0,
335
+ ok: 1,
336
+ }
337
+ it(`should get ${JSON.stringify(vans[1])} for delAll`, async function() {
338
+ assert.strict.deepStrictEqual(vget[1], vans[1])
339
+ })
340
+
341
+ vans[2] = { n: 3, nInserted: 3, ok: 1 }
342
+ it(`should get ${JSON.stringify(vans[2])} for insert`, async function() {
343
+ assert.strict.deepStrictEqual(vget[2], vans[2])
344
+ })
345
+
346
+ vans[3] = [
347
+ { n: 1, nModified: 1, ok: 1 },
348
+ { n: 1, nModified: 1, ok: 1 },
349
+ { n: 0, nModified: 0, ok: 1 }
350
+ ]
351
+ it(`should get ${JSON.stringify(vans[3])} for save(autoInsert=false)`, async function() {
352
+ assert.strict.deepStrictEqual(vget[3], vans[3])
353
+ })
354
+
355
+ vans[4] = [
356
+ {
357
+ // id: {random id},
358
+ name: 'kettle',
359
+ value: 456
360
+ },
361
+ { id: 'id-peter', name: 'peter(modify)', value: 123 },
362
+ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
363
+ ]
364
+ it(`should get ${JSON.stringify(vans[4])} for select all`, async function() {
365
+ assert.strict.deepStrictEqual(vget[4], vans[4])
366
+ })
367
+
368
+ vans[5] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
369
+ it(`should get ${JSON.stringify(vans[5])} for select`, async function() {
370
+ assert.strict.deepStrictEqual(vget[5], vans[5])
371
+ })
372
+
373
+ vans[6] = [{ id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }]
374
+ it(`should get ${JSON.stringify(vans[6])} for select by $and, $gt, $lt`, async function() {
375
+ assert.strict.deepStrictEqual(vget[6], vans[6])
376
+ })
377
+
378
+ vans[7] = [
379
+ {
380
+ // id: {random id},
381
+ name: 'kettle',
382
+ value: 456
383
+ }
384
+ ]
385
+ it(`should get ${JSON.stringify(vans[7])} for select by $or, $gte, $lte`, async function() {
386
+ assert.strict.deepStrictEqual(vget[7], vans[7])
387
+ })
388
+
389
+ vans[8] = [
390
+ {
391
+ // id: {random id},
392
+ name: 'kettle',
393
+ value: 456
394
+ },
395
+ {
396
+ id: 'id-rosemary',
397
+ name: 'rosemary(modify)',
398
+ value: 123.456
399
+ }
400
+ ]
401
+ it(`should get ${JSON.stringify(vans[8])} for select by $or, $and, $ne, $in, $nin`, async function() {
402
+ assert.strict.deepStrictEqual(vget[8], vans[8])
403
+ })
404
+
405
+ // vans[9] = [{ id: 'id-peter', name: 'peter(modify)', value: 123 }]
406
+ // it(`should get ${JSON.stringify(vans[9])} for select by regex`, async function() {
407
+ // assert.strict.deepStrictEqual(vget[9], vans[9])
408
+ // })
409
+
410
+ vans[10] = [{ n: 1, nModified: 1, ok: 1 }]
411
+ it(`should get ${JSON.stringify(vans[10])} for save(autoInsert=true)`, async function() {
412
+ assert.strict.deepStrictEqual(vget[10], vans[10])
413
+ })
414
+
415
+ vans[11] = [{ n: 1, nDeleted: 1, ok: 1 }]
416
+ it(`should get ${JSON.stringify(vans[11])} for del`, async function() {
417
+ assert.strict.deepStrictEqual(vget[11], vans[11])
418
+ })
419
+
420
+ })
395
421