@cocreate/indexeddb 1.5.18 → 1.5.20
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 +16 -0
- package/package.json +4 -4
- package/src/index.js +19 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [1.5.20](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.5.19...v1.5.20) (2022-12-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies ([6252da8](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/6252da814b0e865843291335566bcb2ebfe06b08))
|
|
7
|
+
|
|
8
|
+
## [1.5.19](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.5.18...v1.5.19) (2022-12-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump dependencies ([ab43233](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/ab43233da8b839b163a5b739e4dfba9ca9063c58))
|
|
14
|
+
* convert doument to array ([d936e71](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/d936e71c2978ffab5c4e3c87474443c14396683a))
|
|
15
|
+
* readDoument cases ([3579985](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/357998527832df23cc9ca9c9dcad7c2f7ecbbe53))
|
|
16
|
+
|
|
1
17
|
## [1.5.18](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.5.17...v1.5.18) (2022-12-27)
|
|
2
18
|
|
|
3
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/indexeddb",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.20",
|
|
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",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"webpack-log": "^3.0.1"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@cocreate/docs": "^1.4.
|
|
64
|
-
"@cocreate/hosting": "^1.6.
|
|
65
|
-
"@cocreate/utils": "^1.17.
|
|
63
|
+
"@cocreate/docs": "^1.4.27",
|
|
64
|
+
"@cocreate/hosting": "^1.6.28",
|
|
65
|
+
"@cocreate/utils": "^1.17.9"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/index.js
CHANGED
|
@@ -414,13 +414,13 @@ const index = (action, data) => {
|
|
|
414
414
|
let databases = data.database;
|
|
415
415
|
if (!Array.isArray(databases))
|
|
416
416
|
databases = [databases]
|
|
417
|
+
|
|
418
|
+
let collections = data.collection;
|
|
419
|
+
if (!Array.isArray(collections))
|
|
420
|
+
collections = [collections]
|
|
417
421
|
|
|
418
422
|
let databasesLength = databases.length
|
|
419
423
|
for (let database of databases) {
|
|
420
|
-
let collections = data.collection;
|
|
421
|
-
if (!Array.isArray(collections))
|
|
422
|
-
collections = [collections]
|
|
423
|
-
|
|
424
424
|
let collectionsLength = collections.length
|
|
425
425
|
for (let collection of collections) {
|
|
426
426
|
getDatabase({database}).then((db) => {
|
|
@@ -552,28 +552,31 @@ const document = (action, data) => {
|
|
|
552
552
|
|
|
553
553
|
if (data.request)
|
|
554
554
|
data[type] = data.request
|
|
555
|
+
|
|
556
|
+
if (data.document && !Array.isArray(data.document))
|
|
557
|
+
data.document = [data.document]
|
|
555
558
|
|
|
556
559
|
if (!data['timeStamp'])
|
|
557
560
|
data['timeStamp'] = new Date().toISOString()
|
|
558
|
-
|
|
561
|
+
|
|
559
562
|
let databases = data.database;
|
|
560
563
|
if (!Array.isArray(databases))
|
|
561
564
|
databases = [databases]
|
|
562
565
|
|
|
566
|
+
let collections = data.collection;
|
|
567
|
+
if (!Array.isArray(collections))
|
|
568
|
+
collections = [collections]
|
|
569
|
+
|
|
563
570
|
let databasesLength = databases.length
|
|
564
571
|
for (let database of databases) {
|
|
565
572
|
getDatabase({database}).then((db) => {
|
|
566
|
-
let collections = data.collection;
|
|
567
|
-
if (!Array.isArray(collections))
|
|
568
|
-
collections = [collections]
|
|
569
|
-
|
|
570
573
|
let collectionsLength = collections.length
|
|
571
574
|
for (let collection of collections) {
|
|
572
575
|
let collectionExist = db.objectStoreNames.contains(collection)
|
|
573
576
|
if (!collectionExist) {
|
|
574
577
|
db.close()
|
|
575
578
|
getDatabase({database, collection}).then((db) => {
|
|
576
|
-
if (data.filter || action == 'readDocument') {
|
|
579
|
+
if (data.filter || action == 'readDocument' && (!data.document || !data.document.length)) {
|
|
577
580
|
db.close()
|
|
578
581
|
readDocuments(data, database, collection).then((filterDocs) => {
|
|
579
582
|
getDatabase({database}).then((db) => {
|
|
@@ -624,7 +627,8 @@ const document = (action, data) => {
|
|
|
624
627
|
})
|
|
625
628
|
|
|
626
629
|
} else {
|
|
627
|
-
if (data.filter || action == 'readDocument') {
|
|
630
|
+
if (data.filter || action == 'readDocument' && (!data.document || !data.document.length)) {
|
|
631
|
+
|
|
628
632
|
db.close()
|
|
629
633
|
readDocuments(data, database, collection).then((filterDocs) => {
|
|
630
634
|
getDatabase({database}).then((db) => {
|
|
@@ -681,10 +685,10 @@ function runDocs({action, data, objectStore, documents, filterDocs, database, co
|
|
|
681
685
|
|
|
682
686
|
if (Array.isArray(data[type]))
|
|
683
687
|
docs.push(...data[type]);
|
|
684
|
-
else if (data[type] != undefined && action == 'createDocument')
|
|
685
|
-
|
|
686
|
-
else if (data[type] != undefined)
|
|
687
|
-
|
|
688
|
+
// else if (data[type] != undefined && action == 'createDocument')
|
|
689
|
+
// docs.push(data[type])
|
|
690
|
+
// else if (data[type] != undefined)
|
|
691
|
+
// docs.push({...data[type]})
|
|
688
692
|
|
|
689
693
|
|
|
690
694
|
if (filterDocs && filterDocs.length) {
|