@aegis-framework/artemis 0.3.26 → 0.3.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aegis-framework/artemis",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Aegis Framework Javascript Library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/artemis.js",
@@ -32,9 +32,11 @@ export class IndexedDB {
32
32
  this.name = name;
33
33
  this.version = version;
34
34
  this.store = store;
35
- this.props = props;
35
+ this.props = props || {};
36
36
  this.index = index;
37
37
 
38
+ this.keyPath = props.keyPath || 'id';
39
+
38
40
  this.upgrades = {};
39
41
 
40
42
  if (this.version === '') {
@@ -138,7 +140,9 @@ export class IndexedDB {
138
140
  const transaction = this.storage.transaction (this.store, 'readwrite').objectStore (this.store);
139
141
  let op;
140
142
  if (key !== null) {
141
- op = transaction.put (Object.assign ({}, {id: key}, value));
143
+ const temp = {};
144
+ temp[this.keyPath] = key;
145
+ op = transaction.put (Object.assign ({}, temp, value));
142
146
  } else {
143
147
  op = transaction.add (value);
144
148
  }
@@ -211,7 +215,16 @@ export class IndexedDB {
211
215
  const transaction = this.storage.transaction (this.store).objectStore (this.store);
212
216
  const op = transaction.getAll ();
213
217
 
214
- op.addEventListener ('success', (event) => {resolve (event.target.result);});
218
+ op.addEventListener ('success', (event) => {
219
+ const results = {};
220
+ event.target.result.forEach((item) => {
221
+ const id = item[this.keyPath];
222
+ delete item[this.keyPath];
223
+
224
+ results[id] = item;
225
+ });
226
+ resolve (results);
227
+ });
215
228
  op.addEventListener ('error', (event) => {reject (event);});
216
229
  });
217
230
  });