@cocreate/indexeddb 1.16.1 → 1.16.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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +41 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.16.2](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.16.1...v1.16.2) (2023-10-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* expanded the try catch ([ab77e43](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/ab77e434f4811832089d63256afb8e678209b4f7))
|
|
7
|
+
|
|
1
8
|
## [1.16.1](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.16.0...v1.16.1) (2023-10-25)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -105,7 +105,6 @@ async function send(data) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
108
|
return createData(data, newData, type)
|
|
110
109
|
|
|
111
110
|
} catch (error) {
|
|
@@ -423,48 +422,48 @@ async function processIndex(data, newData, database, array, type) {
|
|
|
423
422
|
async function processObject(data, newData, database, array, type) {
|
|
424
423
|
let db = await processDatabase({ method: 'get.database', database })
|
|
425
424
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
425
|
+
try {
|
|
426
|
+
let isFilter
|
|
427
|
+
if (data.$filter && data.$filter.query)
|
|
428
|
+
isFilter = true
|
|
429
|
+
|
|
430
|
+
let arrayExist = db.objectStoreNames.contains(array)
|
|
431
|
+
if (!arrayExist) {
|
|
432
|
+
if (data.method == 'create.object' || data.method == 'update.object') {
|
|
433
|
+
db.close()
|
|
434
|
+
db = await processDatabase({ method: 'get.database', database, array })
|
|
435
|
+
} else {
|
|
436
|
+
return errorHandler(data, "array does not exist", database, array)
|
|
437
|
+
}
|
|
437
438
|
}
|
|
438
|
-
}
|
|
439
439
|
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
if (!array || !db)
|
|
441
|
+
throw new Error({ error: "This is an error message.", db, array });
|
|
442
442
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
443
|
+
if (!data[type])
|
|
444
|
+
data[type] = []
|
|
445
|
+
if (data[type] && !Array.isArray(data[type]))
|
|
446
|
+
data[type] = [data[type]]
|
|
446
447
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (!data[type])
|
|
450
|
-
data[type] = []
|
|
451
|
-
if (data[type] && !Array.isArray(data[type]))
|
|
452
|
-
data[type] = [data[type]]
|
|
448
|
+
if (isFilter && !data[type].length)
|
|
449
|
+
data[type] = [{}]
|
|
453
450
|
|
|
454
|
-
|
|
455
|
-
data
|
|
451
|
+
let transactionType = "readwrite" //test
|
|
452
|
+
if (data.method == 'read.object')
|
|
453
|
+
transactionType = "readonly"
|
|
456
454
|
|
|
457
|
-
|
|
458
|
-
|
|
455
|
+
let transaction = db.transaction([array], transactionType);
|
|
456
|
+
let objectStore = transaction.objectStore(array);
|
|
459
457
|
|
|
460
|
-
|
|
461
|
-
let
|
|
462
|
-
count.onsuccess = function () {
|
|
463
|
-
data.$filter.count = count.result
|
|
464
|
-
}
|
|
465
|
-
}
|
|
458
|
+
let globalOperators = getGlobalOperators(data)
|
|
459
|
+
let upsert = data.upsert
|
|
466
460
|
|
|
467
|
-
|
|
461
|
+
if (data.$filter) {
|
|
462
|
+
let count = objectStore.count();
|
|
463
|
+
count.onsuccess = function () {
|
|
464
|
+
data.$filter.count = count.result
|
|
465
|
+
}
|
|
466
|
+
}
|
|
468
467
|
|
|
469
468
|
for (let i = 0; i < data[type].length; i++) {
|
|
470
469
|
delete data[type][i].$storage
|
|
@@ -572,11 +571,16 @@ async function processObject(data, newData, database, array, type) {
|
|
|
572
571
|
}
|
|
573
572
|
|
|
574
573
|
}
|
|
574
|
+
|
|
575
|
+
if (db.close)
|
|
576
|
+
db.close()
|
|
577
|
+
|
|
575
578
|
} catch (error) {
|
|
576
579
|
errorHandler(data, error, database, array)
|
|
577
|
-
|
|
580
|
+
if (db.close)
|
|
581
|
+
db.close()
|
|
578
582
|
|
|
579
|
-
|
|
583
|
+
}
|
|
580
584
|
}
|
|
581
585
|
|
|
582
586
|
function openCursor(objectStore, range, direction, data, newData, isFilter, limit, database, array, upsert, type, i, globalOperators) {
|