@cocreate/indexeddb 1.9.0 → 1.9.1

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.9.1](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.9.0...v1.9.1) (2023-05-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * duplicate keys ([e87668f](https://github.com/CoCreate-app/CoCreate-indexeddb/commit/e87668f17412e08a1497a53acbf7ba8592b53756))
7
+
1
8
  # [1.9.0](https://github.com/CoCreate-app/CoCreate-indexeddb/compare/v1.8.7...v1.9.0) (2023-05-10)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/indexeddb",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
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
@@ -1016,10 +1016,14 @@ async function readDocs(data, database, collection, objectStore, direction) {
1016
1016
  });
1017
1017
  }
1018
1018
 
1019
- function generateDB(organization = {document: {}}, user = {document: {}}) {
1020
- const organization_id = organization._id || ObjectId();
1021
- const primaryKey = organization.key || uuid.generate();
1022
- const user_id = user._id || ObjectId();
1019
+ async function generateDB(organization = {document: {}}, user = {document: {}}) {
1020
+ const organization_id = organization.document._id || ObjectId();
1021
+ const primaryKey = organization.document.key || uuid.generate();
1022
+ const user_id = user.document._id || ObjectId();
1023
+
1024
+ let apiKey = await readDocument({database: organization_id, collection: 'keys', organization_id})
1025
+ if (apiKey && apiKey.document && apiKey.document[0])
1026
+ return
1023
1027
 
1024
1028
  try {
1025
1029
  // Create organization