@cocreate/indexeddb 1.13.3 → 1.13.5

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [1.13.5](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.13.4...v1.13.5) (2023-09-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Add path and pathname ([9324f2b](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/9324f2b2088060ac9dd44e8479538328cacb99e7))
7
+ * Update CoCreate depndencies to latest versions ([635996b](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/635996bdde146f632eab7bc8cc4f674d6f5b585f))
8
+
9
+ ## [1.13.4](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.13.3...v1.13.4) (2023-09-17)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * renamed filter to $filter ([00c58a5](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/00c58a585b27e88c735a35e9a85cf234b060347c))
15
+ * update indexeddb() to indexeddb.send() ([6568ef6](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/6568ef68d4f38490ffc57086661d4a5b8ae3b721))
16
+
1
17
  ## [1.13.3](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.13.2...v1.13.3) (2023-09-07)
2
18
 
3
19
 
@@ -8,18 +8,17 @@ module.exports = {
8
8
  "object": {
9
9
  "_id": "637ca2aa50234ef1671ce308",
10
10
  "name": "index.html",
11
- "path": "/docs/indexeddb/index.html",
11
+ "path": "/docs/indexeddb",
12
+ "pathname": "/docs/indexeddb/index.html",
12
13
  "src": "{{./docs/index.html}}",
13
14
  "host": [
14
15
  "cocreate.app",
15
16
  "general.cocreate.app"
16
17
  ],
17
- "directory": "/docs/indexeddb",
18
- "parentDirectory": "{{parentDirectory}}",
18
+ "directory": "indexeddb",
19
19
  "content-type": "{{content-type}}",
20
- "public": "true",
21
- "website_id": "644d4bff8036fb9d1d1fd69c"
20
+ "public": "true"
22
21
  }
23
22
  }
24
23
  ]
25
- }
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.13.3",
3
+ "version": "1.13.5",
4
4
  "description": "A simple indexeddb component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "indexeddb",
@@ -58,6 +58,6 @@
58
58
  "webpack-log": "^3.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@cocreate/utils": "^1.24.0"
61
+ "@cocreate/utils": "^1.24.1"
62
62
  }
63
63
  }
package/src/index.js CHANGED
@@ -49,14 +49,14 @@ function setStatus(value) {
49
49
 
50
50
  if (!value) {
51
51
  indexedDbFunction = indexedDb
52
- indexedDb = value;
53
- } else if (!indexedDb) {
54
- indexedDb = indexedDbFunction
52
+ send = value;
53
+ } else if (!send) {
54
+ send = indexedDbFunction
55
55
  indexedDbFunction = true
56
56
  }
57
57
  }
58
58
 
59
- async function indexedDb(data) {
59
+ async function send(data) {
60
60
  try {
61
61
  let newData = [];
62
62
 
@@ -118,12 +118,12 @@ const processDatabase = (data, newData, type) => {
118
118
  if (data.method == 'read.database') {
119
119
  indexedDB.databases().then((databases) => {
120
120
  for (let database of databases) {
121
- if (data.filter && data.filter.query) {
122
- let isFilter = queryData(database, data.filter.query)
121
+ if (data.$filter && data.$filter.query) {
122
+ let isFilter = queryData(database, data.$filter.query)
123
123
  if (isFilter)
124
- newData.push({ storage: 'indexeddb', database })
124
+ newData.push({ $storage: 'indexeddb', $database: database })
125
125
  } else
126
- newData.push({ storage: 'indexeddb', database })
126
+ newData.push({ $storage: 'indexeddb', $database: database })
127
127
  }
128
128
 
129
129
  resolve()
@@ -299,12 +299,12 @@ async function processArray(data, newData, database, type) {
299
299
  data[type] = []
300
300
 
301
301
  for (let i = 0; i < objectStoreNames.length; i++) {
302
- if (data.filter && data.filter.query) {
303
- let isFilter = queryData({ name: objectStoreNames[i] }, data.filter.query)
302
+ if (data.$filter && data.$filter.query) {
303
+ let isFilter = queryData({ name: objectStoreNames[i] }, data.$filter.query)
304
304
  if (isFilter)
305
- newData.push({ name: objectStoreNames, storage: 'indexeddb', database })
305
+ newData.push({ name: objectStoreNames, $storage: 'indexeddb', $database: database })
306
306
  } else
307
- newData.push({ name: objectStoreNames[i], storage: 'indexeddb', database })
307
+ newData.push({ name: objectStoreNames[i], $storage: 'indexeddb', $database: database })
308
308
  }
309
309
  } else {
310
310
  let arrays
@@ -345,7 +345,7 @@ async function processArray(data, newData, database, type) {
345
345
  db.result.close()
346
346
 
347
347
  if (!error)
348
- newData.push({ name: array, storage: 'indexeddb', database })
348
+ newData.push({ name: array, $storage: 'indexeddb', $database: database })
349
349
  else
350
350
  errorHandler(data, error, database)
351
351
  }
@@ -364,10 +364,10 @@ async function processIndex(data, newData, database, array, type) {
364
364
  if (data.method == 'read.index') {
365
365
  for (let i = 0; i < indexNames.length; i++) {
366
366
  let name = indexNames[i]
367
- if (data.filter && data.filter.query)
368
- if (!(queryData({ name }, data.filter.query))) continue
367
+ if (data.$filter && data.$filter.query)
368
+ if (!(queryData({ name }, data.$filter.query))) continue
369
369
 
370
- newData.push({ name, storage: 'indexeddb', database, array })
370
+ newData.push({ name, $storage: 'indexeddb', $database: database, $array: array })
371
371
  }
372
372
  db.close()
373
373
  } else {
@@ -407,7 +407,7 @@ async function processIndex(data, newData, database, array, type) {
407
407
  error = 'index does not exist'
408
408
 
409
409
  if (!error)
410
- newData.push({ name: index, storage: 'indexeddb', database, array })
410
+ newData.push({ name: index, $storage: 'indexeddb', $database: database, $array: array })
411
411
  else
412
412
  errorHandler(data, error, database, array)
413
413
 
@@ -419,303 +419,256 @@ async function processIndex(data, newData, database, array, type) {
419
419
 
420
420
  async function processObject(data, newData, database, array, type) {
421
421
  let db = await processDatabase({ method: 'get.database', database })
422
- let filteredObjects
422
+
423
+ let isFilter
424
+ if (data.$filter && data.$filter.query)
425
+ isFilter = true
426
+
423
427
  let arrayExist = db.objectStoreNames.contains(array)
424
- if (arrayExist) {
425
- if (data.filter || data.method == 'read.object' && (!data.object || data.object && !data.object.length)) {
426
- db.close()
427
- filteredObjects = await readObject(data, database, array)
428
- db = await processDatabase({ method: 'get.database', database })
429
- }
430
- } else {
431
- db.close()
432
- db = processDatabase({ method: 'get.database', database, array })
433
- if (data.filter || data.method == 'read.object' && (!data.object || !data.object.length)) {
428
+ if (!arrayExist) {
429
+ if (data.$filter || data.method == 'read.object' && (!data.object || data.object && !data.object.length)) {
434
430
  db.close()
435
- filteredObjects = await readObject(data, database, array)
436
- db = processDatabase({ method: 'get.database', database })
431
+ db = await processDatabase({ method: 'get.database', database, array })
437
432
  }
438
433
  }
439
434
 
440
- // let transaction, objectStore
441
- if (array && db) {
442
- var transaction = db.transaction([array], "readwrite");
443
- var objectStore = transaction.objectStore(array);
444
- }
435
+ if (!array || !db)
436
+ throw new Error({ error: "This is an error message.", db, array });
445
437
 
446
- let objects = []
438
+ let transactionType = "readwrite"
439
+ if (data.method == 'read.object')
440
+ transactionType = "readonly"
447
441
 
448
- if (Array.isArray(data[type]))
449
- objects.push(...data[type]);
450
- else if (data[type] != undefined)
451
- objects.push(data[type])
452
- // else if (data[type] != undefined && data.method == 'create.object')
453
- // objects.push(data[type])
454
- // else if (data[type] != undefined)
455
- // objects.push({...data[type]})
442
+ let transaction = db.transaction([array], transactionType);
443
+ let objectStore = transaction.objectStore(array);
456
444
 
445
+ if (data[type] && !Array.isArray(data[type]))
446
+ data[type] = [data[type]]
457
447
 
458
- if (filteredObjects && filteredObjects.length) {
459
- if (data.method == 'read.object') {
460
- for (let i = 0; i < filteredObjects.length; i++)
461
- newData.push({ storage: 'indexeddb', database, array, ...filteredObjects[i] })
448
+ if (isFilter && (!data[type] || !data[type].length))
449
+ data[type] = [{}]
462
450
 
463
- }
451
+ let upsert = data.upsert
452
+ try {
464
453
 
465
- if (data.method == 'update.object') {
466
- let updateData = objects[0];
467
- if (updateData)
468
- objects.shift();
469
- for (let filterDoc of filteredObjects) {
470
- filterDoc = dotNotationToObject(updateData, filterDoc)
471
- objects.push(filterDoc)
472
- }
473
- }
454
+ for (let i = 0; i < data[type].length; i++) {
455
+ delete data[type][i].$storage
456
+ delete data[type][i].$database
457
+ delete data[type][i].$array
474
458
 
475
- if (data.method == 'delete.object')
476
- objects.push(...filteredObjects)
477
- }
459
+ if (data.method == 'create.object') {
460
+ if (!data[type][i]._id)
461
+ data[type][i]['_id'] = ObjectId()
462
+ data[type][i] = dotNotationToObject(data[type][i])
463
+ data[type][i]['created'] = { on: data.timeStamp, by: data.user_id || data.clientId }
478
464
 
479
- for (let i = 0; i < objects.length; i++) {
480
- // TODO deDuplcate object per array
481
- delete objects[i].storage
482
- delete objects[i].database
483
- delete objects[i].array
484
-
485
- if (data.method == 'update.object' || data.method == 'delete.object') {
486
- if (objects[i]._id) {
465
+ let result = await add(objectStore, data[type][i])
466
+ newData.push({ $storage: 'indexeddb', $database: database, $array: array, ...result })
467
+ } else {
468
+ if (data[type][i].$filter)
469
+ isFilter = true
487
470
  if (data.organization_id)
488
- objects[i]['organization_id'] = data.organization_id
489
- objects[i]['modified'] = { on: data.timeStamp, by: data.user_id || data.clientId }
490
-
491
- await updateObject(data, objects[i], objectStore, database, array)
492
- objects[i].storage = 'indexeddb'
493
- objects[i].database = database
494
- objects[i].array = array
495
- newData.push(objects[i])
496
- }
497
- } else if (data.method == 'create.object') {
498
- if (!objects[i]._id)
499
- objects[i]['_id'] = ObjectId()
500
- objects[i] = dotNotationToObject(objects[i])
501
-
502
- if (data.organization_id)
503
- objects[i]['organization_id'] = data.organization_id
504
- objects[i]['created'] = { on: data.timeStamp, by: data.user_id || data.clientId }
505
- await addGet(data, newData, database, array, objects[i], objectStore, 'add')
506
- } else if (data.method == 'read.object') {
507
- if (objects[i]._id)
508
- await addGet(data, newData, database, array, objects[i]._id, objectStore, 'get')
509
- else
510
- errorHandler(data, { message: 'requires _id', object: objects[i] }, database, objectStore.name)
511
- }
512
-
513
- }
471
+ data[type][i]['organization_id'] = data.organization_id
514
472
 
515
- db.close()
516
- }
517
-
518
- function addGet(data, newData, database, array, object, objectStore, operator) {
519
- return new Promise((resolve, reject) => {
520
- let request = objectStore[operator](object)
473
+ if (data.method == 'update.object') {
474
+ if (data[type][i].$upsert)
475
+ upsert = data[type][i].$upsert
521
476
 
522
- request.onsuccess = function () {
523
- if (request.result) {
524
- if (data.method == 'read.object')
525
- object = request.result
526
- object.storage = 'indexeddb'
527
- object.database = database
528
- object.array = array
529
-
530
- newData.push(object)
531
- }
532
- resolve()
533
- };
477
+ if (!data[type][i]._id && upsert)
478
+ data[type][i]._id = ObjectId()
479
+ data[type][i]['modified'] = { on: data.timeStamp, by: data.user_id || data.clientId }
480
+ }
534
481
 
535
- request.onerror = function () {
536
- errorHandler(data, { message: request.error, object }, database, objectStore.name)
537
- resolve()
538
- };
482
+ let index = 0, limit, range, direction
483
+ if (data[type][i]._id)
484
+ range = IDBKeyRange.only(data[type][i]._id);
485
+ else if (isFilter) {
486
+ if (data.$filter || object.$filter) {
487
+ let count = objectStore.count();
488
+ count.onsuccess = function () {
489
+ data.$filter.count = count.result
490
+ }
491
+ }
539
492
 
540
- });
541
- }
493
+ let isIndex = false
494
+ let indexName, direction;
495
+ if (data.$filter && data.$filter.sort && data.$filter.sort[0] && data.$filter.sort[0].name) {
496
+ indexName = data.$filter.sort[0].name
497
+ // if (indexName.includes('-'))
498
+ // isIndex = false
499
+ // else
500
+ // isIndex = true
501
+ }
542
502
 
543
- function updateObject(data, doc, objectStore, database, array) {
544
- return new Promise((resolve, reject) => {
545
- let get = objectStore.get(doc._id)
546
- get.onsuccess = function () {
547
- let result = get.result
548
- if (result || data.upsert == true) {
549
- let modify = true
550
- if (result && doc.modified && result.modified)
551
- if (doc.modified.on < result.modified.on)
552
- modify = false
553
-
554
- if (modify) {
555
- if (data.method == 'update.object') {
556
- doc = dotNotationToObject(doc, get.result)
557
-
558
- if (data.updateName) {
559
- for (let key of Object.keys(data.updateName)) {
560
- let val = doc[key]
561
- delete doc[key]
562
- doc[data.updateName[key]] = val
503
+ if (isIndex) {
504
+ direction = data.$filter.sort[0].direction
505
+ if (direction == 'desc')
506
+ direction = 'prev'
507
+ else
508
+ direction = 'next'
509
+
510
+ let indexNames = Array.from(objectStore.indexNames)
511
+ let indexExist = indexNames.includes(indexName)
512
+ if (!indexExist) {
513
+ db.close()
514
+ db = await processDatabase({ method: 'get.database', database, upgrade: true })
515
+ transaction = db.transaction([array], 'readwrite');
516
+ objectStore = transaction.objectStore(array);
517
+ try {
518
+ objectStore.createIndex(indexName, indexName, { unique: false })
519
+ } catch (error) {
520
+ // console.log(error)
563
521
  }
564
522
  }
523
+ objectStore = objectStore.index(indexName);
524
+ }
565
525
 
566
- if (data.deleteName) {
567
- for (let key of Object.keys(data.deleteName)) {
568
- delete doc[key]
569
- }
526
+ if (data.$filter) {
527
+ if (data.$filter.index)
528
+ index = data.$filter.index
529
+ if (data.$filter.limit)
530
+ limit = data.$filter.limit
531
+ if (limit)
532
+ limit = index + limit;
533
+ }
534
+ }
570
535
 
536
+ let cursor = await openCursor(objectStore, range, direction)
537
+ if (cursor) {
538
+ let isMatch = true
539
+
540
+ if (isFilter)
541
+ isMatch = filter(objectStore, data[type][i], cursor.value)
542
+
543
+ if (isMatch !== false) {
544
+ let result
545
+ if (data.method == 'create.object') {
546
+ result = await add(objectStore, data[type][i])
547
+ } else if (data.method == 'read.object') {
548
+ result = await get(objectStore, data[type][i])
549
+ } else if (data.method == 'update.object') {
550
+ data[type][i] = dotNotationToObject(data[type][i], cursor.value)
551
+ data[type][i] = createUpdate(data, data[type][i])
552
+ result = await put(objectStore, data[type][i])
553
+ } else if (data.method == 'delete.object') {
554
+ result = await deleteObject(objectStore, data[type][i])
571
555
  }
572
556
 
573
- let put = objectStore.put(doc);
557
+ newData.push({ $storage: 'indexeddb', $database: database, $array: array, ...result })
558
+ }
574
559
 
575
- put.onsuccess = function () {
576
- resolve(doc)
577
- };
560
+ limit && limit == newData.length ? '' : cursor.continue();
578
561
 
579
- put.onerror = function () {
580
- errorHandler(data, put.error, database, array, doc)
581
- resolve(doc)
582
- };
562
+ } else if (index)
563
+ newData = newData.slice(index)
564
+ }
565
+ }
566
+ } catch (error) {
567
+ errorHandler(data, error, database, array)
568
+ }
583
569
 
584
- }
570
+ db.close()
571
+ }
585
572
 
586
- if (data.method == 'delete.object') {
587
- let deleteDoc = objectStore.delete(doc._id);
573
+ function openCursor(objectStore, range, direction) {
574
+ return new Promise(async (resolve, reject) => {
575
+ const request = objectStore.openCursor(range, direction);// next, prev
576
+ request.onsuccess = () => resolve(request.result);
577
+ request.onerror = () => reject(request.error)
578
+ });
579
+ }
588
580
 
589
- deleteDoc.onsuccess = function () {
590
- resolve(doc)
591
- };
581
+ function add(objectStore, object) {
582
+ return new Promise((resolve, reject) => {
583
+ const request = objectStore.add(object);
584
+ request.onsuccess = () => resolve(object);
585
+ request.onerror = () => reject(request.error);
586
+ });
587
+ }
592
588
 
593
- deleteDoc.onerror = function () {
594
- errorHandler(data, deleteDoc.error, database, array, doc)
595
- resolve(doc)
596
- };
597
- }
589
+ function get(objectStore, object) {
590
+ return new Promise((resolve, reject) => {
591
+ const request = objectStore.get(object._id);
592
+ request.onsuccess = () => resolve(request.result);
593
+ request.onerror = () => reject(request.error);
594
+ });
595
+ }
598
596
 
599
- } else {
600
- // TODO: handle if _id not found upsert
601
- errorHandler(data, 'doc in db is newer', database, array, doc)
602
- resolve(doc)
603
- }
604
- } else {
605
- errorHandler(data, 'object doest not exist and upsert is not true', database, array, doc)
606
- resolve(doc)
607
- }
597
+ function put(objectStore, object) {
598
+ return new Promise((resolve, reject) => {
599
+ const request = objectStore.put(object);
600
+ request.onsuccess = () => resolve(object);
601
+ request.onerror = () => reject(request.error);
602
+ });
603
+ }
608
604
 
609
- };
605
+ function deleteObject(objectStore, object) {
606
+ return new Promise((resolve, reject) => {
607
+ const request = objectStore.delete(object._id);
608
+ request.onsuccess = () => resolve(object);
609
+ request.onerror = () => reject(request.error);
610
+ });
611
+ }
610
612
 
611
- get.onerror = function () {
612
- errorHandler(data, get.error, database, array, doc)
613
- resolve(doc)
614
- };
615
613
 
616
- })
617
- }
614
+ function createUpdate(data, object) {
615
+ if (data.updateName) {
616
+ for (let key of Object.keys(data.updateName)) {
617
+ let val = object[key]
618
+ delete object[key]
619
+ object[data.updateName[key]] = val
620
+ }
621
+ }
618
622
 
619
- function readObject(data, database, array) {
620
- return new Promise(async (resolve, reject) => {
623
+ if (data.deleteName) {
624
+ for (let key of Object.keys(data.deleteName)) {
625
+ delete object[key]
626
+ }
621
627
 
622
- try {
623
- let db = await processDatabase({ method: 'get.database', database })
624
- let transaction = db.transaction([array], "readonly");
625
- let objectStore = transaction.objectStore(array);
626
-
627
- if (data.filter) {
628
- let count = objectStore.count();
629
- count.onsuccess = function () {
630
- data.filter.count = count.result
631
- }
632
- }
628
+ }
629
+ return object
630
+ }
633
631
 
634
- let isIndex = false
635
- let indexName, direction;
636
- if (data.filter && data.filter.sort && data.filter.sort[0] && data.filter.sort[0].name) {
637
- indexName = data.filter.sort[0].name
638
- // if (indexName.includes('-'))
639
- // isIndex = false
640
- // else
641
- // isIndex = true
642
- }
632
+ function filter(data, object, result) {
633
+ let isMatch = true;
643
634
 
644
- if (isIndex) {
645
- direction = data.filter.sort[0].direction
646
- if (direction == 'desc')
647
- direction = 'prev'
648
- else
649
- direction = 'next'
650
-
651
- let indexNames = Array.from(objectStore.indexNames)
652
- let indexExist = indexNames.includes(indexName)
653
- if (!indexExist) {
654
- db.close()
655
- db = await processDatabase({ method: 'get.database', database, upgrade: true })
656
- transaction = db.transaction;
657
- objectStore = transaction.objectStore(array);
658
- try {
659
- objectStore.createIndex(indexName, indexName, { unique: false })
660
- } catch (error) {
661
- // console.log(error)
662
- }
663
- }
664
- objectStore = objectStore.index(indexName);
665
- }
635
+ if (data.$filter || object.$filter) {
636
+ let count = objectStore.count();
637
+ count.onsuccess = function () {
638
+ data.$filter.count = count.result
639
+ }
640
+ }
666
641
 
667
- let results = [], index = 0, limit
668
- if (data.filter) {
669
- if (data.filter.index)
670
- index = data.filter.index
671
- if (data.filter.limit)
672
- limit = data.filter.limit
673
- if (limit)
674
- limit = index + limit;
675
- }
642
+ if (data.$filter) {
643
+ if (data.$filter.query)
644
+ isMatch = queryData(result, data.$filter.query);
645
+ if (isMatch && data.$filter.search)
646
+ isMatch = searchData(result, data.$filter.search);
647
+ }
676
648
 
677
- const request = objectStore.openCursor(null, direction);
678
- request.onsuccess = function () {
679
- let cursor = request.result;
680
- if (cursor) {
681
- let isFilter = true;
682
- let value = cursor.value;
683
- if (data.filter) {
684
- if (data.filter.query)
685
- isFilter = queryData(value, data.filter.query);
686
- if (isFilter && data.filter.search)
687
- isFilter = searchData(value, data.filter.search);
688
- }
689
- if (isFilter !== false)
690
- results.push(value)
691
- if (limit && limit == results.length) {
692
- results = results.slice(index, limit)
693
- resolve(results)
694
- } else
695
- cursor.continue();
696
- } else {
697
- if (index)
698
- results = results.slice(index)
699
- resolve(results)
700
- }
701
- }
649
+ let modify = true
650
+ if (result && object.modified && result.modified)
651
+ if (object.modified.on < result.modified.on)
652
+ modify = false
702
653
 
703
- request.onerror = function () {
704
- errorHandler(data, request.error, database, array)
705
- db.close()
706
- resolve([])
707
- };
654
+ return isMatch
655
+ }
708
656
 
657
+ function createData(data, newData, type) {
658
+ data.request = data[type] || {}
709
659
 
710
- if (db && db.close)
711
- db.close()
712
- // return results
660
+ if (data.$filter && data.$filter.sort)
661
+ data[type] = sortData(newData, data.$filter.sort)
662
+ else
663
+ data[type] = newData
713
664
 
714
- } catch (error) {
715
- errorHandler(data, error, database, array)
716
- resolve([])
717
- }
718
- });
665
+ if (data.returnLog) {
666
+ if (!data.log)
667
+ data.log = []
668
+ data.log.push(...data[type])
669
+ }
670
+
671
+ return data
719
672
  }
720
673
 
721
674
  function errorHandler(data, error, database, array) {
@@ -734,23 +687,6 @@ function errorHandler(data, error, database, array) {
734
687
  data.error = [error]
735
688
  }
736
689
 
737
- function createData(data, newData, type) {
738
- data.request = data[type] || {}
739
-
740
- if (data.filter && data.filter.sort)
741
- data[type] = sortData(newData, data.filter.sort)
742
- else
743
- data[type] = newData
744
-
745
- if (data.returnLog) {
746
- if (!data.log)
747
- data.log = []
748
- data.log.push(...data[type])
749
- }
750
-
751
- return data
752
- }
753
-
754
690
  init();
755
691
 
756
- export default indexedDb
692
+ export default { send }
package/test/documents.js CHANGED
@@ -50,7 +50,7 @@ async function testDocuments() {
50
50
  // object: {
51
51
  // _id
52
52
  // }
53
- filter: {
53
+ $filter: {
54
54
  query: [
55
55
  { key: 'organization_id', value: "5ff747727005da1c272740ab" }
56
56
  ]