w-orm-lowdb 1.0.7 → 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,415 +1,417 @@
1
1
  import assert from 'assert'
2
- import fs from 'node:fs/promises'
3
2
  import WOrm from '../src/WOrmLowdb.mjs'
4
3
  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
- //wo
62
- let wo = WOrm(opt)
63
-
64
- //on
65
- wo.on('change', function(mode, data, res) {
66
- // console.log('change', mode)
67
- })
68
-
69
- //delAll
70
- rt = null
71
- vans[1] = {
72
- nDeleted: 0,
73
- ok: 1,
74
- }
75
- await wo.delAll()
76
- .then(function(msg) {
77
- // console.log('delAll then', msg)
78
- //考慮可能有不同初始測試數據
79
- // delAll then { n: 2, nDeleted: 2, ok: 1 }
80
- // delAll then { n: 3, nDeleted: 2, ok: 1 }
81
- //僅針對nDeleted與ok欄位比對
82
- rt = {
83
- nDeleted: msg.nDeleted,
84
- ok: msg.ok,
85
- }
86
- })
87
- .catch(function(msg) {
88
- // console.log('delAll catch', msg)
89
- rt = msg.toString()
90
- })
91
- vget[1] = rt
92
-
93
- //insert
94
- rt = null
95
- vans[2] = { n: 3, nInserted: 3, ok: 1 }
96
- await wo.insert(rs)
97
- .then(function(msg) {
98
- // console.log('insert then', msg)
99
- // insert then { n: 3, nInserted: 3, ok: 1 }
100
- rt = msg
101
- })
102
- .catch(function(msg) {
103
- // console.log('insert catch', msg)
104
- rt = msg.toString()
105
- })
106
- vget[2] = rt
107
-
108
- //save
109
- rt = null
110
- vans[3] = [
111
- { n: 1, nModified: 1, ok: 1 },
112
- { n: 1, nModified: 1, ok: 1 },
113
- { n: 0, nModified: 0, ok: 1 }
114
- ]
115
- await wo.save(rsm, { autoInsert: false })
116
- .then(function(msg) {
117
- // console.log('save then', msg)
118
- // save then [
119
- // { n: 1, nModified: 1, ok: 1 },
120
- // { n: 1, nModified: 1, ok: 1 },
121
- // { n: 0, nModified: 0, ok: 1 }
122
- // ]
123
- rt = msg
124
- })
125
- .catch(function(msg) {
126
- // console.log('save catch', msg)
127
- rt = msg.toString()
128
- })
129
- vget[3] = rt
130
-
131
- //select all
132
- rt = null
133
- vans[4] = [
134
- { id: 'id-peter', name: 'peter(modify)', value: 123 },
135
- { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
136
- {
137
- // id: {random id},
138
- name: 'kettle',
139
- value: 456
140
- }
141
- ]
142
- await wo.select()
143
- .then(function(msg) {
144
- // console.log('select all then', msg)
145
- // select all [
146
- // { id: 'id-peter', name: 'peter(modify)', value: 123 },
147
- // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 },
148
- // {
149
- // id: {random id},
150
- // name: 'kettle',
151
- // value: 456
152
- // }
153
- // ]
154
- rt = [
155
- msg[0],
156
- msg[1],
157
- {
158
- name: msg[2].name,
159
- value: msg[2].value,
160
- },
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
- // select by $or, $and, $ne, $in, $nin [
249
- // {
250
- // id: 'id-rosemary',
251
- // name: 'rosemary(modify)',
252
- // value: 123.456
253
- // },
254
- // {
255
- // id: {random id},
256
- // name: 'kettle',
257
- // value: 456
258
- // }
259
- // ]
260
- rt = [
261
- msg[0],
262
- {
263
- name: msg[1].name,
264
- value: msg[1].value,
265
- },
266
- ]
267
- })
268
- .catch(function(msg) {
269
- // console.log('select by $or, $and, $ne, $in, $nin catch', msg)
270
- rt = msg.toString()
271
- })
272
- vget[8] = rt
273
-
274
- // //select by regex
275
- // rt = null
276
- // vans[9] = [{ id: 'id-peter', name: 'peter(modify)', value: 123 }]
277
- // await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
278
- // .then(function(msg) {
279
- // // console.log('select by regex then', msg)
280
- // // selectReg [ { id: 'id-peter', name: 'peter(modify)', value: 123 } ]
281
- // rt = msg
282
- // })
283
- // .catch(function(msg) {
284
- // // console.log('select by regex catch', msg)
285
- // rt = msg.toString()
286
- // })
287
- // vget[9] = rt
288
-
289
- //del
290
- rt = null
291
- vans[10] = [{ n: 1, nDeleted: 1, ok: 1 }]
292
- let ss = await wo.select()
293
- let d = ss.filter(function(v) {
294
- return v.name === 'kettle'
295
- })
296
- await wo.del(d)
297
- .then(function(msg) {
298
- // console.log('del then', msg)
299
- // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
300
- rt = msg
301
- })
302
- .catch(function(msg) {
303
- // console.log('del catch', msg)
304
- rt = msg.toString()
305
- })
306
- vget[10] = rt
307
-
308
- })
309
-
310
- it(`should get ${JSON.stringify(vans[1])} for delAll`, async function() {
311
- assert.strict.deepStrictEqual(vget[1], vans[1])
312
- })
313
-
314
- it(`should get ${JSON.stringify(vans[2])} for insert`, async function() {
315
- assert.strict.deepStrictEqual(vget[2], vans[2])
316
- })
317
-
318
- it(`should get ${JSON.stringify(vans[3])} for save`, async function() {
319
- assert.strict.deepStrictEqual(vget[3], vans[3])
320
- })
321
-
322
- it(`should get ${JSON.stringify(vans[4])} for select all`, async function() {
323
- assert.strict.deepStrictEqual(vget[4], vans[4])
324
- })
325
-
326
- it(`should get ${JSON.stringify(vans[5])} for select`, async function() {
327
- assert.strict.deepStrictEqual(vget[5], vans[5])
328
- })
329
-
330
- it(`should get ${JSON.stringify(vans[6])} for select by $and, $gt, $lt`, async function() {
331
- assert.strict.deepStrictEqual(vget[6], vans[6])
332
- })
333
-
334
- it(`should get ${JSON.stringify(vans[7])} for select by $or, $gte, $lte`, async function() {
335
- assert.strict.deepStrictEqual(vget[7], vans[7])
336
- })
337
-
338
- it(`should get ${JSON.stringify(vans[8])} for select by $or, $and, $ne, $in, $nin`, async function() {
339
- assert.strict.deepStrictEqual(vget[8], vans[8])
340
- })
341
-
342
- // it(`should get ${JSON.stringify(vans[9])} for select by regex`, async function() {
343
- // assert.strict.deepStrictEqual(vget[9], vans[9])
344
- // })
345
-
346
- it(`should get ${JSON.stringify(vans[10])} for del`, async function() {
347
- assert.strict.deepStrictEqual(vget[10], vans[10])
348
- })
349
-
350
- })
351
4
 
352
- describe('save autoInsert', function() {
353
- let url = './tmp/save-autoinsert.test.json'
354
5
 
355
- beforeEach(async function() {
356
- await fs.mkdir('./tmp', { recursive: true })
357
- await fs.rm(url, { force: true })
358
- })
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
+ ]
359
61
 
360
- afterEach(async function() {
361
- await fs.rm(url, { force: true })
62
+ //wo
63
+ let wo = WOrm(opt)
64
+
65
+ //on
66
+ wo.on('change', function(mode, data, res) {
67
+ // console.log('change', mode)
362
68
  })
363
69
 
364
- it('should preserve updated data when a later item is auto inserted', async function() {
365
- let wo = WOrm({
366
- url,
367
- db: 'worm',
368
- cl: 'items',
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
369
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
370
169
 
371
- await wo.insert({
372
- id: 'a',
373
- n: 1,
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()
374
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
375
289
 
376
- let res = await wo.save([
377
- {
378
- id: 'a',
379
- n: 2,
380
- },
381
- {
382
- id: 'b',
383
- n: 3,
384
- },
385
- ])
386
-
387
- assert.strict.deepStrictEqual(res, [
388
- {
389
- n: 1,
390
- nModified: 1,
391
- ok: 1,
392
- },
393
- {
394
- n: 1,
395
- nInserted: 1,
396
- ok: 1,
397
- },
398
- ])
399
-
400
- let rows = await wo.select()
401
- assert.strict.deepStrictEqual(rows, [
402
- {
403
- id: 'a',
404
- n: 2,
405
- },
406
- {
407
- id: 'b',
408
- n: 3,
409
- },
410
- ])
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'
411
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
+ })
412
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])
413
363
  })
414
- }
415
-
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
+ })