w-orm-lowdb 1.0.8 → 1.0.9

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