w-orm-postgresql 1.0.1 → 1.0.2

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.
@@ -89,7 +89,7 @@ if (isWindows()) {
89
89
  },
90
90
  ]
91
91
 
92
- let rsm = [
92
+ let rsm = [
93
93
  { //相同
94
94
  time: '2025-01-01T00:09:00Z',
95
95
  name: 'peter',
@@ -113,11 +113,18 @@ if (isWindows()) {
113
113
  { //無time須新增且新增數據無value
114
114
  time: '2025-01-01T00:13:00Z',
115
115
  name: 'sandler',
116
- },
117
- ]
118
-
119
- //wo
120
- let wo = WOrm(opt)
116
+ },
117
+ ]
118
+
119
+ let rsa = [
120
+ {
121
+ time: '2025-01-01T00:13:00Z',
122
+ name: 'sandler',
123
+ },
124
+ ]
125
+
126
+ //wo
127
+ let wo = WOrm(opt)
121
128
 
122
129
  //on
123
130
  wo.on('change', function(mode, data, res) {
@@ -169,27 +176,27 @@ if (isWindows()) {
169
176
 
170
177
  //save
171
178
  rt = null
172
- vans[3] = [
173
- { n: 1, nModified: 0, ok: 1 },
174
- { n: 1, nModified: 1, ok: 1 },
175
- { n: 1, nModified: 1, ok: 1 },
176
- { n: 1, nModified: 1, ok: 1 },
177
- { n: 1, nInserted: 1, ok: 1 }
178
- ]
179
- await wo.save(rsm, { autoInsert: true })
180
- .then(function(msg) {
181
- // console.log('save then', msg)
182
- rt = msg
183
- })
179
+ vans[3] = [
180
+ { n: 1, nModified: 0, ok: 1 },
181
+ { n: 1, nModified: 1, ok: 1 },
182
+ { n: 1, nModified: 1, ok: 1 },
183
+ { n: 1, nModified: 1, ok: 1 },
184
+ { n: 0, nModified: 0, ok: 1 }
185
+ ]
186
+ await wo.save(rsm, { autoInsert: false })
187
+ .then(function(msg) {
188
+ // console.log('save then', msg)
189
+ rt = msg
190
+ })
184
191
  .catch(function(msg) {
185
192
  // console.log('save catch', msg)
186
193
  rt = msg.toString()
187
- })
188
- vget[3] = rt
189
-
190
- //select all
191
- rt = null
192
- vans[4] = [
194
+ })
195
+ vget[3] = rt
196
+
197
+ //select all
198
+ rt = null
199
+ vans[4] = [
193
200
  { time: new Date('2025-01-01T00:00:00.000Z'), name: 'peter', value: 123 },
194
201
  { time: new Date('2025-01-01T00:01:00.000Z'), name: 'rosemary', value: 123.456 },
195
202
  { time: new Date('2025-01-01T00:02:00.000Z'), name: 'kettle', value: 456 },
@@ -199,26 +206,39 @@ if (isWindows()) {
199
206
  { time: new Date('2025-01-01T00:06:00.000Z'), name: 'peter', value: 125 },
200
207
  { time: new Date('2025-01-01T00:07:00.000Z'), name: 'rosemary', value: 124.76 },
201
208
  { time: new Date('2025-01-01T00:08:00.000Z'), name: 'kettle', value: 524 },
202
- { time: new Date('2025-01-01T00:09:00.000Z'), name: 'peter', value: 127 },
203
- { time: new Date('2025-01-01T00:10:00.000Z'), name: 'rosemary(modify)', value: 113.98 },
204
- { time: new Date('2025-01-01T00:11:00.000Z'), name: 'kettle(modify)', value: 447 },
205
- { time: new Date('2025-01-01T00:12:00.000Z'), name: 'peter', value: 99 },
206
- { time: new Date('2025-01-01T00:13:00.000Z'), name: 'sandler', value: null }
207
- ]
208
- await wo.select()
209
- .then(function(msg) {
210
- // console.log('select all then', msg)
211
- rt = msg
212
- })
209
+ { time: new Date('2025-01-01T00:09:00.000Z'), name: 'peter', value: 127 },
210
+ { time: new Date('2025-01-01T00:10:00.000Z'), name: 'rosemary(modify)', value: 113.98 },
211
+ { time: new Date('2025-01-01T00:11:00.000Z'), name: 'kettle(modify)', value: 447 },
212
+ { time: new Date('2025-01-01T00:12:00.000Z'), name: 'peter', value: 99 }
213
+ ]
214
+ await wo.select()
215
+ .then(function(msg) {
216
+ // console.log('select all then', msg)
217
+ rt = msg
218
+ })
213
219
  .catch(function(msg) {
214
220
  // console.log('select all catch', msg)
215
221
  rt = msg.toString()
216
- })
217
- vget[4] = rt
218
-
219
- //select by name
220
- rt = null
221
- vans[5] = [
222
+ })
223
+ vget[4] = rt
224
+
225
+ //select all by cache
226
+ rt = null
227
+ vans[5] = vans[4]
228
+ await wo.select()
229
+ .then(function(msg) {
230
+ // console.log('select all by cache then', msg)
231
+ rt = msg
232
+ })
233
+ .catch(function(msg) {
234
+ // console.log('select all by cache catch', msg)
235
+ rt = msg.toString()
236
+ })
237
+ vget[5] = rt
238
+
239
+ //select by name
240
+ rt = null
241
+ vans[6] = [
222
242
  { time: new Date('2025-01-01T00:01:00.000Z'), name: 'rosemary', value: 123.456 },
223
243
  { time: new Date('2025-01-01T00:04:00.000Z'), name: 'rosemary', value: 123.1236 },
224
244
  { time: new Date('2025-01-01T00:07:00.000Z'), name: 'rosemary', value: 124.76 }
@@ -232,11 +252,11 @@ if (isWindows()) {
232
252
  // console.log('select all catch', msg)
233
253
  rt = msg.toString()
234
254
  })
235
- vget[5] = rt
255
+ vget[6] = rt
236
256
 
237
257
  //select by $and, $gt, $lt
238
258
  rt = null
239
- vans[6] = [
259
+ vans[7] = [
240
260
  { time: new Date('2025-01-01T00:01:00.000Z'), name: 'rosemary', value: 123.456 },
241
261
  { time: new Date('2025-01-01T00:04:00.000Z'), name: 'rosemary', value: 123.1236 },
242
262
  { time: new Date('2025-01-01T00:06:00.000Z'), name: 'peter', value: 125 },
@@ -252,11 +272,11 @@ if (isWindows()) {
252
272
  // console.log('select all catch', msg)
253
273
  rt = msg.toString()
254
274
  })
255
- vget[6] = rt
275
+ vget[7] = rt
256
276
 
257
277
  //select by $or, $gte, $lte
258
278
  rt = null
259
- vans[7] = [
279
+ vans[8] = [
260
280
  { time: new Date('2025-01-01T00:02:00.000Z'), name: 'kettle', value: 456 },
261
281
  { time: new Date('2025-01-01T00:03:00.000Z'), name: 'peter', value: 200 },
262
282
  { time: new Date('2025-01-01T00:05:00.000Z'), name: 'kettle', value: 488 },
@@ -272,11 +292,11 @@ if (isWindows()) {
272
292
  // console.log('select all catch', msg)
273
293
  rt = msg.toString()
274
294
  })
275
- vget[7] = rt
295
+ vget[8] = rt
276
296
 
277
297
  //select by $or, $and, $ne, $in, $nin
278
298
  rt = null
279
- vans[8] = [
299
+ vans[9] = [
280
300
  { time: new Date('2025-01-01T00:01:00.000Z'), name: 'rosemary', value: 123.456 },
281
301
  { time: new Date('2025-01-01T00:02:00.000Z'), name: 'kettle', value: 456 },
282
302
  { time: new Date('2025-01-01T00:05:00.000Z'), name: 'kettle', value: 488 },
@@ -292,11 +312,11 @@ if (isWindows()) {
292
312
  // console.log('select all catch', msg)
293
313
  rt = msg.toString()
294
314
  })
295
- vget[8] = rt
315
+ vget[9] = rt
296
316
 
297
317
  // //select by regex
298
318
  // rt = null
299
- // vans[9] = []
319
+ // vans[14] = []
300
320
  // let sr = await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
301
321
  // .then(function(msg) {
302
322
  // // console.log('select all then', msg)
@@ -305,12 +325,26 @@ if (isWindows()) {
305
325
  // .catch(function(msg) {
306
326
  // // console.log('select all catch', msg)
307
327
  // rt = msg.toString()
308
- // })
309
- // vget[9] = rt
310
-
311
- //del
312
- rt = null
313
- vans[10] = [{ n: 1, nDeleted: 0, ok: 1 }]
328
+ // })
329
+ // vget[14] = rt
330
+
331
+ //save
332
+ rt = null
333
+ vans[10] = [{ n: 1, nInserted: 1, ok: 1 }]
334
+ await wo.save(rsa, { autoInsert: true })
335
+ .then(function(msg) {
336
+ // console.log('save then', msg)
337
+ rt = msg
338
+ })
339
+ .catch(function(msg) {
340
+ // console.log('save catch', msg)
341
+ rt = msg.toString()
342
+ })
343
+ vget[10] = rt
344
+
345
+ //del
346
+ rt = null
347
+ vans[11] = [{ n: 1, nDeleted: 0, ok: 1 }]
314
348
  let d = {
315
349
  time: '2024-01-01T00:00:00Z',
316
350
  }
@@ -323,11 +357,11 @@ if (isWindows()) {
323
357
  // console.log('del catch', msg)
324
358
  rt = msg.toString()
325
359
  })
326
- vget[10] = rt
327
-
328
- //del
329
- rt = null
330
- vans[11] = [
360
+ vget[11] = rt
361
+
362
+ //del
363
+ rt = null
364
+ vans[12] = [
331
365
  { n: 1, nDeleted: 1, ok: 1 },
332
366
  { n: 1, nDeleted: 1, ok: 1 },
333
367
  { n: 1, nDeleted: 1, ok: 1 },
@@ -352,11 +386,11 @@ if (isWindows()) {
352
386
  // console.log('del catch', msg)
353
387
  rt = msg.toString()
354
388
  })
355
- vget[11] = rt
356
-
357
- //select all final
358
- rt = null
359
- vans[12] = [
389
+ vget[12] = rt
390
+
391
+ //select all final
392
+ rt = null
393
+ vans[13] = [
360
394
  { time: new Date('2025-01-01T00:01:00.000Z'), name: 'rosemary', value: 123.456 },
361
395
  { time: new Date('2025-01-01T00:04:00.000Z'), name: 'rosemary', value: 123.1236 },
362
396
  { time: new Date('2025-01-01T00:07:00.000Z'), name: 'rosemary', value: 124.76 },
@@ -371,7 +405,7 @@ if (isWindows()) {
371
405
  // console.log('select all catch', msg)
372
406
  rt = msg.toString()
373
407
  })
374
- vget[12] = rt
408
+ vget[13] = rt
375
409
 
376
410
  })
377
411
 
@@ -383,45 +417,53 @@ if (isWindows()) {
383
417
  assert.strict.deepStrictEqual(vget[2], vans[2])
384
418
  })
385
419
 
386
- it(`should get ${JSON.stringify(vans[3])} for save`, async function() {
387
- assert.strict.deepStrictEqual(vget[3], vans[3])
388
- })
389
-
390
- it(`should get ${JSON.stringify(vans[4])} for select all`, async function() {
391
- assert.strict.deepStrictEqual(vget[4], vans[4])
392
- })
393
-
394
- it(`should get ${JSON.stringify(vans[5])} for select by name`, async function() {
395
- assert.strict.deepStrictEqual(vget[5], vans[5])
396
- })
397
-
398
- it(`should get ${JSON.stringify(vans[6])} for select by $and, $gt, $lt`, async function() {
399
- assert.strict.deepStrictEqual(vget[6], vans[6])
400
- })
401
-
402
- it(`should get ${JSON.stringify(vans[7])} for select by $or, $gte, $lte`, async function() {
403
- assert.strict.deepStrictEqual(vget[7], vans[7])
404
- })
405
-
406
- it(`should get ${JSON.stringify(vans[8])} for select by $or, $and, $ne, $in, $nin`, async function() {
407
- assert.strict.deepStrictEqual(vget[8], vans[8])
408
- })
409
-
410
- // it(`should get ${JSON.stringify(vans[9])} for select by regex`, async function() {
411
- // assert.strict.deepStrictEqual(vget[9], vans[9])
412
- // })
413
-
414
- it(`should get ${JSON.stringify(vans[10])} for del`, async function() {
415
- assert.strict.deepStrictEqual(vget[10], vans[10])
416
- })
417
-
418
- it(`should get ${JSON.stringify(vans[11])} for del`, async function() {
419
- assert.strict.deepStrictEqual(vget[11], vans[11])
420
- })
421
-
422
- it(`should get ${JSON.stringify(vans[12])} for select all final`, async function() {
423
- assert.strict.deepStrictEqual(vget[12], vans[12])
424
- })
420
+ it(`should get ${JSON.stringify(vans[3])} for save(autoInsert=false)`, async function() {
421
+ assert.strict.deepStrictEqual(vget[3], vans[3])
422
+ })
423
+
424
+ it(`should get ${JSON.stringify(vans[4])} for select all`, async function() {
425
+ assert.strict.deepStrictEqual(vget[4], vans[4])
426
+ })
427
+
428
+ it(`should get ${JSON.stringify(vans[5])} for select all by cache`, async function() {
429
+ assert.strict.deepStrictEqual(vget[5], vans[5])
430
+ })
431
+
432
+ it(`should get ${JSON.stringify(vans[6])} for select by name`, async function() {
433
+ assert.strict.deepStrictEqual(vget[6], vans[6])
434
+ })
435
+
436
+ it(`should get ${JSON.stringify(vans[7])} for select by $and, $gt, $lt`, async function() {
437
+ assert.strict.deepStrictEqual(vget[7], vans[7])
438
+ })
439
+
440
+ it(`should get ${JSON.stringify(vans[8])} for select by $or, $gte, $lte`, async function() {
441
+ assert.strict.deepStrictEqual(vget[8], vans[8])
442
+ })
443
+
444
+ it(`should get ${JSON.stringify(vans[9])} for select by $or, $and, $ne, $in, $nin`, async function() {
445
+ assert.strict.deepStrictEqual(vget[9], vans[9])
446
+ })
447
+
448
+ // it(`should get ${JSON.stringify(vans[14])} for select by regex`, async function() {
449
+ // assert.strict.deepStrictEqual(vget[14], vans[14])
450
+ // })
451
+
452
+ it(`should get ${JSON.stringify(vans[10])} for save(autoInsert=true)`, async function() {
453
+ assert.strict.deepStrictEqual(vget[10], vans[10])
454
+ })
455
+
456
+ it(`should get ${JSON.stringify(vans[11])} for del`, async function() {
457
+ assert.strict.deepStrictEqual(vget[11], vans[11])
458
+ })
459
+
460
+ it(`should get ${JSON.stringify(vans[12])} for del`, async function() {
461
+ assert.strict.deepStrictEqual(vget[12], vans[12])
462
+ })
463
+
464
+ it(`should get ${JSON.stringify(vans[13])} for select all final`, async function() {
465
+ assert.strict.deepStrictEqual(vget[13], vans[13])
466
+ })
425
467
 
426
468
  })
427
469
  }