@bbn/bbn 1.0.376 → 1.0.378
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/db.js +45 -3
- package/package.json +1 -1
package/dist/db.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
1
10
|
import _ from './_.js';
|
|
2
11
|
import each from './fn/loop/each.js';
|
|
3
12
|
import iterate from './fn/loop/iterate.js';
|
|
@@ -17,6 +26,38 @@ var transformResult = function (obj, fields) {
|
|
|
17
26
|
}
|
|
18
27
|
return obj;
|
|
19
28
|
};
|
|
29
|
+
var fieldsFromFilter = function (filter, fields) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (fields === void 0) { fields = []; }
|
|
32
|
+
if ((_a = filter === null || filter === void 0 ? void 0 : filter.conditions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
33
|
+
filter.conditions.forEach(function (cond) {
|
|
34
|
+
if (cond.field && !fields.includes(cond.field)) {
|
|
35
|
+
fields.push(cond.field);
|
|
36
|
+
}
|
|
37
|
+
else if (cond.conditions) {
|
|
38
|
+
fieldsFromFilter(cond, fields);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (isObject(filter)) {
|
|
43
|
+
iterate(filter, function (v, n) {
|
|
44
|
+
if (!fields.includes(n)) {
|
|
45
|
+
fields.push(n);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else if (isArray(filter)) {
|
|
50
|
+
filter.forEach(function (cond) {
|
|
51
|
+
if (cond.field && !fields.includes(cond.field)) {
|
|
52
|
+
fields.push(cond.field);
|
|
53
|
+
}
|
|
54
|
+
else if (cond.conditions) {
|
|
55
|
+
fieldsFromFilter(cond, fields);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return fields;
|
|
60
|
+
};
|
|
20
61
|
var dbObject = function (dbName) {
|
|
21
62
|
var _this = this;
|
|
22
63
|
var conn = db._connections[dbName];
|
|
@@ -93,8 +134,8 @@ var dbObject = function (dbName) {
|
|
|
93
134
|
this.selectOne = function (table, field, where, order, start, limit) {
|
|
94
135
|
return new Promise(function (resolve) {
|
|
95
136
|
_this.selectAll(table, [field], where, order, start, 1).then(function (d) {
|
|
96
|
-
var _a;
|
|
97
|
-
resolve((_a = d[field]) !== null &&
|
|
137
|
+
var _a, _b;
|
|
138
|
+
resolve((_b = (_a = d === null || d === void 0 ? void 0 : d[0]) === null || _a === void 0 ? void 0 : _a[field]) !== null && _b !== void 0 ? _b : undefined);
|
|
98
139
|
});
|
|
99
140
|
});
|
|
100
141
|
};
|
|
@@ -192,7 +233,8 @@ var db = {
|
|
|
192
233
|
if (!db._structures[name]) {
|
|
193
234
|
throw new Error(_("Impossible to find a structure for the database %s", name));
|
|
194
235
|
}
|
|
195
|
-
var
|
|
236
|
+
var num = Math.max.apply(Math, __spreadArray([1], Object.keys(db._structures[name]).map(function (a) { return db._structures[name][a].num || 1; }), false));
|
|
237
|
+
var conn_1 = idb.open(name, num);
|
|
196
238
|
conn_1.onupgradeneeded = function () {
|
|
197
239
|
log("UPGRADE NEEDED");
|
|
198
240
|
var res = conn_1.result;
|