@cocreate/indexeddb 1.7.10 → 1.7.11

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,10 @@
1
+ ## [1.7.11](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.7.10...v1.7.11) (2023-04-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * replaced object.entries with Object.keys ([385f513](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/385f513429878c9b5e33ef8a91d5b80af43ade32))
7
+
1
8
  ## [1.7.10](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.7.9...v1.7.10) (2023-04-13)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.7.10",
3
+ "version": "1.7.11",
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",
package/src/index.js CHANGED
@@ -55,7 +55,7 @@ const Database = (action, data) => {
55
55
  } else {
56
56
  let databases
57
57
  if (action == 'updateDatabase')
58
- databases = Object.entries(data.database)
58
+ databases = Object.keys(data.database).map((key) => [key, data.database[key]])
59
59
  else
60
60
  databases = data.database;
61
61
 
@@ -279,9 +279,12 @@ const collection = (action, data) => {
279
279
  data[type] = []
280
280
 
281
281
  for (let collection of objectStoreNames){
282
- let isFilter = queryData({name: collection}, data.filter.query)
283
- if (isFilter)
284
- collectionArray.push({name: collection, db: 'indexeddb', database})
282
+ if (data.filter && data.filter.query) {
283
+ let isFilter = queryData({name: collection}, data.filter.query)
284
+ if (isFilter)
285
+ collectionArray.push({name: collection, db: 'indexeddb', database})
286
+ } else
287
+ collectionArray.push({ database, db: 'indexeddb' })
285
288
  }
286
289
 
287
290
  databasesLength -= 1
@@ -292,7 +295,7 @@ const collection = (action, data) => {
292
295
  } else {
293
296
  let collections
294
297
  if (action == 'updateCollection')
295
- collections = Object.entries(data[type])
298
+ collections = Object.keys(data[type]).map((key) => [key, data[type][key]])
296
299
  else
297
300
  collections = data[type];
298
301
  if (!Array.isArray(collections))
@@ -436,10 +439,12 @@ const index = (action, data) => {
436
439
 
437
440
  if (action == 'readIndex') {
438
441
  for (let index of indexNames) {
439
- let isFilter = queryData({name: index}, data.filter.query)
440
- if (isFilter)
441
- indexArray.push({name: index, db: 'indexeddb', database, collection})
442
- }
442
+ if (data.filter && data.filter.query) {
443
+ let isFilter = queryData({name: index}, data.filter.query)
444
+ if (isFilter)
445
+ indexArray.push({name: index, db: 'indexeddb', database, collection})
446
+ } else
447
+ indexArray.push({ database, db: 'indexeddb' }) }
443
448
  collectionsLength -= 1
444
449
  db.close()
445
450
 
@@ -453,7 +458,7 @@ const index = (action, data) => {
453
458
  db.close()
454
459
  let indexes
455
460
  if (action == 'updateIndex')
456
- indexes = Object.entries(data[type])
461
+ indexes = Object.keys(data[type]).map((key) => [key, data[type][key]])
457
462
  else
458
463
  indexes = data[type];
459
464
  if (!Array.isArray(indexes))
@@ -818,10 +823,10 @@ function updateDoc(action, data, doc, objectStore, database, collection) {
818
823
  doc = dotNotationToObject(doc, get.result)
819
824
 
820
825
  if (data.updateName){
821
- for (let [key, value] of Object.entries(data.updateName)){
826
+ for (let key of Object.keys(data.updateName)){
822
827
  let val = doc[key]
823
828
  delete doc[key]
824
- doc[value] = val
829
+ doc[data.updateName[key]] = val
825
830
  }
826
831
  }
827
832
 
package/test/databases.js CHANGED
@@ -5,7 +5,6 @@ async function testDatabases() {
5
5
  } else {
6
6
  let createDatabase = await CoCreate.indexeddb.createDatabase({
7
7
  database: 'testDB',
8
-
9
8
  })
10
9
  console.log('createDatabase', createDatabase)
11
10
 
@@ -14,15 +13,14 @@ async function testDatabases() {
14
13
  })
15
14
  console.log('readDatabase', readDatabase)
16
15
 
17
- // let updateDatabase = await CoCreate.indexeddb.updateDatabase({
18
- // database: 'testDB',
19
- // updateDatabase: {testDatabase: 'testDatabase1'}
20
- // })
21
- // console.log('updateDatabase', updateDatabase)
16
+ let updateDatabase = await CoCreate.indexeddb.updateDatabase({
17
+ database: {testDB: 'testDatabase1'}
18
+ })
19
+ console.log('updateDatabase', updateDatabase)
22
20
 
23
21
 
24
22
  let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
25
- database: 'testDB',
23
+ database: ['testDB', 'testDB1', 'testDB2'],
26
24
  })
27
25
  console.log('deleteDatabase', deleteDatabase)
28
26
 
package/test/index.html CHANGED
@@ -12,8 +12,9 @@
12
12
  <body>
13
13
 
14
14
 
15
- <!-- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script> -->
16
- <script src="../dist/CoCreate-indexeddb.js"></script>
15
+ <!-- <script src="../../../CoCreateJS/dist/CoCreate.js"></script> -->
16
+ <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
17
+ <!-- <script src="../dist/CoCreate-indexeddb.js"></script> -->
17
18
  <script src="./databases.js"></script>
18
19
  <script src="./collections.js"></script>
19
20
  <script src="./indexes.js"></script>