@bbn/bbn 1.0.367 → 1.0.369

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/dist/db.js CHANGED
@@ -41,13 +41,13 @@ import log from './fn/browser/log.js';
41
41
  var idb = window['indexedDB'] || window['webkitIndexedDB'] || window['mozIndexedDB'] || window['OIndexedDB'] || window['msIndexedDB'];
42
42
  var dbObject = function (dbName) {
43
43
  var _this = this;
44
+ var conn = db._connections[dbName];
44
45
  var structure = db._structures[dbName];
45
46
  this.insert = function (table, data) {
46
47
  if (!Array.isArray(data)) {
47
48
  data = [data];
48
49
  }
49
50
  return new Promise(function (resolve) {
50
- var conn = db._connections[dbName];
51
51
  var tx = conn.transaction(table, "readwrite");
52
52
  var store = tx.objectStore(table);
53
53
  var res = data.length;
@@ -68,7 +68,6 @@ var dbObject = function (dbName) {
68
68
  };
69
69
  this.update = function (table, data, where) {
70
70
  return new Promise(function (resolve) {
71
- var conn = db._connections[dbName];
72
71
  var tx = conn.transaction(table, "readwrite");
73
72
  var store = tx.objectStore(table);
74
73
  var arch = structure[table];
@@ -77,7 +76,8 @@ var dbObject = function (dbName) {
77
76
  throw new Error(_("No "));
78
77
  }
79
78
  var res = 1;
80
- var request = store.put(data, where[primary]);
79
+ data[primary] = where[primary];
80
+ var request = store.put(data);
81
81
  request.onerror = function () {
82
82
  log(request.error);
83
83
  res--;
@@ -92,7 +92,6 @@ var dbObject = function (dbName) {
92
92
  };
93
93
  this.delete = function (table, where) {
94
94
  return new Promise(function (resolve) {
95
- var conn = db._connections[dbName];
96
95
  var tx = conn.transaction(table, "readwrite");
97
96
  var store = tx.objectStore(table);
98
97
  var arch = structure[table];
@@ -123,9 +122,8 @@ var dbObject = function (dbName) {
123
122
  });
124
123
  };
125
124
  this.select = function (table, fields, where, order, start, limit) { return __awaiter(_this, void 0, void 0, function () {
126
- var conn, tx, store, arch, primary;
125
+ var tx, store, arch, primary;
127
126
  return __generator(this, function (_a) {
128
- conn = db._connections[dbName];
129
127
  tx = conn.transaction(table, "readonly");
130
128
  store = tx.objectStore(table);
131
129
  arch = structure[table];
@@ -154,7 +152,6 @@ var dbObject = function (dbName) {
154
152
  });
155
153
  }); };
156
154
  this.selectAll = function (table, fields, where, order, start, limit) {
157
- var conn = db._connections[dbName];
158
155
  var tx = conn.transaction(table, "read");
159
156
  var store = tx.objectStore(table);
160
157
  var arch = structure[table];
@@ -168,7 +165,6 @@ var dbObject = function (dbName) {
168
165
  };
169
166
  this.getColumnValues = function (table, field, where, order, start, limit) {
170
167
  return new Promise(function (resolve) {
171
- var conn = db._connections[dbName];
172
168
  var tx = conn.transaction(table, "read");
173
169
  var store = tx.objectStore(table);
174
170
  });
@@ -210,7 +206,7 @@ var db = {
210
206
  };
211
207
  }
212
208
  else {
213
- resolve(new dbObject(db._connections[name]));
209
+ resolve(new dbObject(name));
214
210
  }
215
211
  });
216
212
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.367",
3
+ "version": "1.0.369",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",