@aws-amplify/datastore 4.0.10 → 4.0.11-unstableV5.4
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/lib/datastore/datastore.js.map +1 -1
- package/lib/predicates/next.d.ts +58 -1
- package/lib/predicates/next.js +120 -37
- package/lib/predicates/next.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +11 -1
- package/lib/storage/adapter/IndexedDBAdapter.js +243 -114
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/predicates/next.d.ts +58 -1
- package/lib-esm/predicates/next.js +120 -37
- package/lib-esm/predicates/next.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +11 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +243 -114
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/package.json +8 -8
- package/src/datastore/datastore.ts +0 -1
- package/src/predicates/next.ts +114 -23
- package/src/storage/adapter/IndexedDBAdapter.ts +185 -58
|
@@ -5,6 +5,28 @@ import { ModelPredicateCreator } from '../../predicates';
|
|
|
5
5
|
import { isPredicateObj, isPredicateGroup, OpType, QueryOne, } from '../../types';
|
|
6
6
|
import { getIndex, getIndexFromAssociation, isModelConstructor, isPrivateMode, traverseModel, validatePredicate, inMemoryPagination, keysEqual, getStorename, getIndexKeys, extractPrimaryKeyValues, isSafariCompatabilityMode, } from '../../util';
|
|
7
7
|
var logger = new Logger('DataStore');
|
|
8
|
+
/**
|
|
9
|
+
* The point after which queries composed of multiple simple OR conditions
|
|
10
|
+
* should scan-and-filter instead of individual queries for each condition.
|
|
11
|
+
*
|
|
12
|
+
* At some point, this should be configurable and/or dynamic based on table
|
|
13
|
+
* size and possibly even on observed average seek latency. For now, it's
|
|
14
|
+
* based on an manual "binary search" for the breakpoint as measured in the
|
|
15
|
+
* unit test suite. This isn't necessarily optimal. But, it's at least derived
|
|
16
|
+
* empirically, rather than theoretically and without any verification!
|
|
17
|
+
*
|
|
18
|
+
* REMEMBER! If you run more realistic benchmarks and update this value, update
|
|
19
|
+
* this comment so the validity and accuracy of future query tuning exercises
|
|
20
|
+
* can be compared to the methods used to derive the current value. E.g.,
|
|
21
|
+
*
|
|
22
|
+
* 1. In browser benchmark > unit test benchmark
|
|
23
|
+
* 2. Multi-browser benchmark > single browser benchmark
|
|
24
|
+
* 3. Benchmarks of various table sizes > static table size benchmark
|
|
25
|
+
*
|
|
26
|
+
* etc...
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
var MULTI_OR_CONDITION_SCAN_BREAKPOINT = 7;
|
|
8
30
|
var DB_NAME = 'amplify-datastore';
|
|
9
31
|
var IndexedDBAdapter = /** @class */ (function () {
|
|
10
32
|
function IndexedDBAdapter() {
|
|
@@ -501,140 +523,247 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
501
523
|
}
|
|
502
524
|
return keyValues.length === keyPath.length ? keyValues : undefined;
|
|
503
525
|
};
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
526
|
+
/**
|
|
527
|
+
* Tries to generate an index fetcher for the given predicates. Assumes
|
|
528
|
+
* that the given predicate conditions are contained by an AND group and
|
|
529
|
+
* should therefore all match a single record.
|
|
530
|
+
*
|
|
531
|
+
* @param storeName The table to query.
|
|
532
|
+
* @param predicates The predicates to try to AND together.
|
|
533
|
+
* @param transaction
|
|
534
|
+
*/
|
|
535
|
+
IndexedDBAdapter.prototype.matchingIndexQueries = function (storeName, predicates, transaction) {
|
|
536
|
+
var e_4, _a, e_5, _b;
|
|
537
|
+
var _this = this;
|
|
538
|
+
// could be expanded later to include `exec()` and a `cardinality` estimate?
|
|
539
|
+
var queries = [];
|
|
540
|
+
var predicateIndex = new Map();
|
|
507
541
|
try {
|
|
508
|
-
for (var
|
|
509
|
-
var
|
|
510
|
-
|
|
511
|
-
if (idx.keyPath === fieldName) {
|
|
512
|
-
return idx;
|
|
513
|
-
}
|
|
542
|
+
for (var predicates_1 = __values(predicates), predicates_1_1 = predicates_1.next(); !predicates_1_1.done; predicates_1_1 = predicates_1.next()) {
|
|
543
|
+
var predicate = predicates_1_1.value;
|
|
544
|
+
predicateIndex.set(String(predicate.field), predicate);
|
|
514
545
|
}
|
|
515
546
|
}
|
|
516
547
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
517
548
|
finally {
|
|
518
549
|
try {
|
|
519
|
-
if (
|
|
550
|
+
if (predicates_1_1 && !predicates_1_1.done && (_a = predicates_1.return)) _a.call(predicates_1);
|
|
520
551
|
}
|
|
521
552
|
finally { if (e_4) throw e_4.error; }
|
|
522
553
|
}
|
|
554
|
+
var store = transaction.objectStore(storeName);
|
|
555
|
+
var _loop_2 = function (name_1) {
|
|
556
|
+
var e_6, _a;
|
|
557
|
+
var idx = store.index(name_1);
|
|
558
|
+
var keypath = Array.isArray(idx.keyPath) ? idx.keyPath : [idx.keyPath];
|
|
559
|
+
var matchingPredicateValues = [];
|
|
560
|
+
try {
|
|
561
|
+
for (var keypath_1 = (e_6 = void 0, __values(keypath)), keypath_1_1 = keypath_1.next(); !keypath_1_1.done; keypath_1_1 = keypath_1.next()) {
|
|
562
|
+
var field = keypath_1_1.value;
|
|
563
|
+
var p = predicateIndex.get(field);
|
|
564
|
+
if (p) {
|
|
565
|
+
matchingPredicateValues.push(String(p.operand));
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
573
|
+
finally {
|
|
574
|
+
try {
|
|
575
|
+
if (keypath_1_1 && !keypath_1_1.done && (_a = keypath_1.return)) _a.call(keypath_1);
|
|
576
|
+
}
|
|
577
|
+
finally { if (e_6) throw e_6.error; }
|
|
578
|
+
}
|
|
579
|
+
// if we have a matching predicate field for each component of this index,
|
|
580
|
+
// we can build a query for it. otherwise, we can't.
|
|
581
|
+
if (matchingPredicateValues.length === keypath.length) {
|
|
582
|
+
// re-create a transaction, because the transaction used to fetch the
|
|
583
|
+
// indexes may no longer be active.
|
|
584
|
+
queries.push(function () {
|
|
585
|
+
return _this.db
|
|
586
|
+
.transaction(storeName)
|
|
587
|
+
.objectStore(storeName)
|
|
588
|
+
.index(name_1)
|
|
589
|
+
.getAll(_this.canonicalKeyPath(matchingPredicateValues));
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
try {
|
|
594
|
+
for (var _c = __values(store.indexNames), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
595
|
+
var name_1 = _d.value;
|
|
596
|
+
_loop_2(name_1);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
600
|
+
finally {
|
|
601
|
+
try {
|
|
602
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
603
|
+
}
|
|
604
|
+
finally { if (e_5) throw e_5.error; }
|
|
605
|
+
}
|
|
606
|
+
return queries;
|
|
523
607
|
};
|
|
524
|
-
IndexedDBAdapter.prototype.
|
|
608
|
+
IndexedDBAdapter.prototype.baseQueryIndex = function (storeName, predicates, transaction) {
|
|
525
609
|
return __awaiter(this, void 0, void 0, function () {
|
|
526
|
-
var predicateObjs, type,
|
|
527
|
-
var e_5, _a, e_6, _b;
|
|
610
|
+
var predicateObjs, type, fieldPredicates, txn, result, groupQueries, objectQueries, indexedQueries;
|
|
528
611
|
var _this = this;
|
|
529
|
-
return __generator(this, function (
|
|
530
|
-
switch (
|
|
612
|
+
return __generator(this, function (_a) {
|
|
613
|
+
switch (_a.label) {
|
|
531
614
|
case 0:
|
|
532
615
|
predicateObjs = predicates.predicates, type = predicates.type;
|
|
533
616
|
// the predicate objects we care about tend to be nested at least
|
|
534
617
|
// one level down: `{and: {or: {and: { <the predicates we want> }}}}`
|
|
535
618
|
// so, we unpack and/or groups until we find a group with more than 1
|
|
536
619
|
// child OR a child that is not a group (and is therefore a predicate "object").
|
|
537
|
-
while (predicateObjs.length === 1 &&
|
|
620
|
+
while (predicateObjs.length === 1 &&
|
|
621
|
+
isPredicateGroup(predicateObjs[0]) &&
|
|
622
|
+
predicateObjs[0].type !== 'not') {
|
|
538
623
|
type = predicateObjs[0].type;
|
|
539
624
|
predicateObjs = predicateObjs[0].predicates;
|
|
540
625
|
}
|
|
541
|
-
fieldPredicates = predicateObjs.filter(function (p) {
|
|
542
|
-
|
|
626
|
+
fieldPredicates = predicateObjs.filter(function (p) { return isPredicateObj(p) && p.operator === 'eq'; });
|
|
627
|
+
txn = transaction || this.db.transaction(storeName);
|
|
628
|
+
result = {};
|
|
629
|
+
if (!(type === 'or')) return [3 /*break*/, 2];
|
|
630
|
+
return [4 /*yield*/, Promise.all(predicateObjs
|
|
631
|
+
.filter(function (o) { return isPredicateGroup(o) && o.type === 'and'; })
|
|
632
|
+
.map(function (o) {
|
|
633
|
+
return _this.baseQueryIndex(storeName, o, txn);
|
|
634
|
+
})).then(function (queries) {
|
|
635
|
+
return queries
|
|
636
|
+
.filter(function (q) { return q.indexedQueries.length === 1; })
|
|
637
|
+
.map(function (i) { return i.indexedQueries; });
|
|
638
|
+
})];
|
|
639
|
+
case 1:
|
|
640
|
+
groupQueries = _a.sent();
|
|
641
|
+
objectQueries = predicateObjs
|
|
642
|
+
.filter(function (o) { return isPredicateObj(o); })
|
|
643
|
+
.map(function (o) {
|
|
644
|
+
return _this.matchingIndexQueries(storeName, [o], txn);
|
|
543
645
|
});
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
646
|
+
indexedQueries = __spread(groupQueries, objectQueries).map(function (q) { return q[0]; })
|
|
647
|
+
.filter(function (i) { return i; });
|
|
648
|
+
// if, after hunting for base queries, we don't have exactly 1 base query
|
|
649
|
+
// for each child group + object, stop trying to optimize. we're not dealing
|
|
650
|
+
// with a simple query that fits the intended optimization path.
|
|
651
|
+
if (predicateObjs.length > indexedQueries.length) {
|
|
652
|
+
result = {
|
|
653
|
+
groupType: null,
|
|
654
|
+
indexedQueries: [],
|
|
549
655
|
};
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
result = {
|
|
659
|
+
groupType: 'or',
|
|
660
|
+
indexedQueries: indexedQueries,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
return [3 /*break*/, 3];
|
|
664
|
+
case 2:
|
|
665
|
+
if (type === 'and') {
|
|
666
|
+
// our potential indexes or lacks thereof.
|
|
667
|
+
// note that we're only optimizing for `eq` right now.
|
|
668
|
+
result = {
|
|
669
|
+
groupType: type,
|
|
670
|
+
indexedQueries: this.matchingIndexQueries(storeName, fieldPredicates, txn),
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
result = {
|
|
675
|
+
groupType: null,
|
|
676
|
+
indexedQueries: [],
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
_a.label = 3;
|
|
680
|
+
case 3:
|
|
681
|
+
if (!!transaction) return [3 /*break*/, 5];
|
|
554
682
|
return [4 /*yield*/, txn.done];
|
|
683
|
+
case 4:
|
|
684
|
+
_a.sent();
|
|
685
|
+
_a.label = 5;
|
|
686
|
+
case 5: return [2 /*return*/, result];
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
IndexedDBAdapter.prototype.filterOnPredicate = function (storeName, predicates) {
|
|
692
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
693
|
+
var predicateObjs, type, _a, groupType, indexedQueries, candidateResults, distinctResults, indexedQueries_1, indexedQueries_1_1, query, resultGroup, resultGroup_1, resultGroup_1_1, item, distinctificationString, e_7_1, filtered;
|
|
694
|
+
var e_7, _b, e_8, _c;
|
|
695
|
+
return __generator(this, function (_d) {
|
|
696
|
+
switch (_d.label) {
|
|
697
|
+
case 0:
|
|
698
|
+
predicateObjs = predicates.predicates, type = predicates.type;
|
|
699
|
+
return [4 /*yield*/, this.baseQueryIndex(storeName, predicates)];
|
|
555
700
|
case 1:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
_c.sent();
|
|
560
|
-
if (!(type === 'and')) return [3 /*break*/, 6];
|
|
561
|
-
actualPredicateIndexes = predicateIndexes.filter(function (i) { return i.index && i.predicate.operator === 'eq'; });
|
|
562
|
-
if (!(actualPredicateIndexes.length > 0)) return [3 /*break*/, 3];
|
|
563
|
-
predicateIndex = actualPredicateIndexes[0];
|
|
564
|
-
return [4 /*yield*/, predicateIndex.index.getAll(predicateIndex.predicate.operand)];
|
|
701
|
+
_a = _d.sent(), groupType = _a.groupType, indexedQueries = _a.indexedQueries;
|
|
702
|
+
if (!(groupType === 'and' && indexedQueries.length > 0)) return [3 /*break*/, 3];
|
|
703
|
+
return [4 /*yield*/, indexedQueries[0]()];
|
|
565
704
|
case 2:
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
705
|
+
// each condition must be satsified, we can form a base set with any
|
|
706
|
+
// ONE of those conditions and then filter.
|
|
707
|
+
candidateResults = _d.sent();
|
|
708
|
+
return [3 /*break*/, 14];
|
|
709
|
+
case 3:
|
|
710
|
+
if (!(groupType === 'or' &&
|
|
711
|
+
indexedQueries.length > 0 &&
|
|
712
|
+
indexedQueries.length <= MULTI_OR_CONDITION_SCAN_BREAKPOINT)) return [3 /*break*/, 12];
|
|
713
|
+
distinctResults = new Map();
|
|
714
|
+
_d.label = 4;
|
|
569
715
|
case 4:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
case 5:
|
|
716
|
+
_d.trys.push([4, 9, 10, 11]);
|
|
717
|
+
indexedQueries_1 = __values(indexedQueries), indexedQueries_1_1 = indexedQueries_1.next();
|
|
718
|
+
_d.label = 5;
|
|
719
|
+
case 5:
|
|
720
|
+
if (!!indexedQueries_1_1.done) return [3 /*break*/, 8];
|
|
721
|
+
query = indexedQueries_1_1.value;
|
|
722
|
+
return [4 /*yield*/, query()];
|
|
574
723
|
case 6:
|
|
575
|
-
|
|
576
|
-
if (!(predicateIndexes.length > 0 &&
|
|
577
|
-
predicateIndexes.every(function (i) { return i.index && i.predicate.operator === 'eq'; }))) return [3 /*break*/, 15];
|
|
578
|
-
distinctResults = new Map();
|
|
579
|
-
_c.label = 7;
|
|
580
|
-
case 7:
|
|
581
|
-
_c.trys.push([7, 12, 13, 14]);
|
|
582
|
-
predicateIndexes_1 = __values(predicateIndexes), predicateIndexes_1_1 = predicateIndexes_1.next();
|
|
583
|
-
_c.label = 8;
|
|
584
|
-
case 8:
|
|
585
|
-
if (!!predicateIndexes_1_1.done) return [3 /*break*/, 11];
|
|
586
|
-
predicateIndex = predicateIndexes_1_1.value;
|
|
587
|
-
return [4 /*yield*/, predicateIndex.index.getAll(predicateIndex.predicate.operand)];
|
|
588
|
-
case 9:
|
|
589
|
-
resultGroup = (_c.sent());
|
|
724
|
+
resultGroup = _d.sent();
|
|
590
725
|
try {
|
|
591
|
-
for (resultGroup_1 = (
|
|
726
|
+
for (resultGroup_1 = (e_8 = void 0, __values(resultGroup)), resultGroup_1_1 = resultGroup_1.next(); !resultGroup_1_1.done; resultGroup_1_1 = resultGroup_1.next()) {
|
|
592
727
|
item = resultGroup_1_1.value;
|
|
593
|
-
|
|
594
|
-
distinctResults.set(
|
|
728
|
+
distinctificationString = JSON.stringify(item);
|
|
729
|
+
distinctResults.set(distinctificationString, item);
|
|
595
730
|
}
|
|
596
731
|
}
|
|
597
|
-
catch (
|
|
732
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
598
733
|
finally {
|
|
599
734
|
try {
|
|
600
|
-
if (resultGroup_1_1 && !resultGroup_1_1.done && (
|
|
735
|
+
if (resultGroup_1_1 && !resultGroup_1_1.done && (_c = resultGroup_1.return)) _c.call(resultGroup_1);
|
|
601
736
|
}
|
|
602
|
-
finally { if (
|
|
737
|
+
finally { if (e_8) throw e_8.error; }
|
|
603
738
|
}
|
|
604
|
-
|
|
739
|
+
_d.label = 7;
|
|
740
|
+
case 7:
|
|
741
|
+
indexedQueries_1_1 = indexedQueries_1.next();
|
|
742
|
+
return [3 /*break*/, 5];
|
|
743
|
+
case 8: return [3 /*break*/, 11];
|
|
744
|
+
case 9:
|
|
745
|
+
e_7_1 = _d.sent();
|
|
746
|
+
e_7 = { error: e_7_1 };
|
|
747
|
+
return [3 /*break*/, 11];
|
|
605
748
|
case 10:
|
|
606
|
-
predicateIndexes_1_1 = predicateIndexes_1.next();
|
|
607
|
-
return [3 /*break*/, 8];
|
|
608
|
-
case 11: return [3 /*break*/, 14];
|
|
609
|
-
case 12:
|
|
610
|
-
e_5_1 = _c.sent();
|
|
611
|
-
e_5 = { error: e_5_1 };
|
|
612
|
-
return [3 /*break*/, 14];
|
|
613
|
-
case 13:
|
|
614
749
|
try {
|
|
615
|
-
if (
|
|
750
|
+
if (indexedQueries_1_1 && !indexedQueries_1_1.done && (_b = indexedQueries_1.return)) _b.call(indexedQueries_1);
|
|
616
751
|
}
|
|
617
|
-
finally { if (
|
|
752
|
+
finally { if (e_7) throw e_7.error; }
|
|
618
753
|
return [7 /*endfinally*/];
|
|
619
|
-
case
|
|
754
|
+
case 11:
|
|
620
755
|
// we could conceivably check for special conditions and return early here.
|
|
621
756
|
// but, this is simpler and has not yet had a measurable performance impact.
|
|
622
757
|
candidateResults = Array.from(distinctResults.values());
|
|
623
|
-
return [3 /*break*/,
|
|
624
|
-
case
|
|
625
|
-
case
|
|
626
|
-
// either no usable indexes or not all conditions can use one.
|
|
627
|
-
candidateResults = (_c.sent());
|
|
628
|
-
_c.label = 17;
|
|
629
|
-
case 17: return [3 /*break*/, 20];
|
|
630
|
-
case 18: return [4 /*yield*/, this.getAll(storeName)];
|
|
631
|
-
case 19:
|
|
758
|
+
return [3 /*break*/, 14];
|
|
759
|
+
case 12: return [4 /*yield*/, this.getAll(storeName)];
|
|
760
|
+
case 13:
|
|
632
761
|
// nothing intelligent we can do with `not` groups unless or until we start
|
|
633
762
|
// smashing comparison operators against indexes -- at which point we could
|
|
634
763
|
// perform some reversal here.
|
|
635
|
-
candidateResults = (
|
|
636
|
-
|
|
637
|
-
case
|
|
764
|
+
candidateResults = (_d.sent());
|
|
765
|
+
_d.label = 14;
|
|
766
|
+
case 14:
|
|
638
767
|
filtered = predicateObjs
|
|
639
768
|
? candidateResults.filter(function (m) { return validatePredicate(m, type, predicateObjs); })
|
|
640
769
|
: candidateResults;
|
|
@@ -815,9 +944,9 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
815
944
|
});
|
|
816
945
|
};
|
|
817
946
|
IndexedDBAdapter.prototype.deleteItem = function (deleteQueue) {
|
|
818
|
-
var
|
|
947
|
+
var e_9, _a, e_10, _b;
|
|
819
948
|
return __awaiter(this, void 0, void 0, function () {
|
|
820
|
-
var connectionStoreNames, tx, _c, _d, deleteItem, storeName, items, store, items_1, items_1_1, item, key, keyValues, itemKey,
|
|
949
|
+
var connectionStoreNames, tx, _c, _d, deleteItem, storeName, items, store, items_1, items_1_1, item, key, keyValues, itemKey, e_10_1, e_9_1;
|
|
821
950
|
return __generator(this, function (_e) {
|
|
822
951
|
switch (_e.label) {
|
|
823
952
|
case 0:
|
|
@@ -871,8 +1000,8 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
871
1000
|
case 12: return [3 /*break*/, 5];
|
|
872
1001
|
case 13: return [3 /*break*/, 20];
|
|
873
1002
|
case 14:
|
|
874
|
-
|
|
875
|
-
|
|
1003
|
+
e_10_1 = _e.sent();
|
|
1004
|
+
e_10 = { error: e_10_1 };
|
|
876
1005
|
return [3 /*break*/, 20];
|
|
877
1006
|
case 15:
|
|
878
1007
|
_e.trys.push([15, , 18, 19]);
|
|
@@ -883,14 +1012,14 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
883
1012
|
_e.label = 17;
|
|
884
1013
|
case 17: return [3 /*break*/, 19];
|
|
885
1014
|
case 18:
|
|
886
|
-
if (
|
|
1015
|
+
if (e_10) throw e_10.error;
|
|
887
1016
|
return [7 /*endfinally*/];
|
|
888
1017
|
case 19: return [7 /*endfinally*/];
|
|
889
1018
|
case 20: return [3 /*break*/, 2];
|
|
890
1019
|
case 21: return [3 /*break*/, 28];
|
|
891
1020
|
case 22:
|
|
892
|
-
|
|
893
|
-
|
|
1021
|
+
e_9_1 = _e.sent();
|
|
1022
|
+
e_9 = { error: e_9_1 };
|
|
894
1023
|
return [3 /*break*/, 28];
|
|
895
1024
|
case 23:
|
|
896
1025
|
_e.trys.push([23, , 26, 27]);
|
|
@@ -901,7 +1030,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
901
1030
|
_e.label = 25;
|
|
902
1031
|
case 25: return [3 /*break*/, 27];
|
|
903
1032
|
case 26:
|
|
904
|
-
if (
|
|
1033
|
+
if (e_9) throw e_9.error;
|
|
905
1034
|
return [7 /*endfinally*/];
|
|
906
1035
|
case 27: return [7 /*endfinally*/];
|
|
907
1036
|
case 28: return [2 /*return*/];
|
|
@@ -911,9 +1040,9 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
911
1040
|
};
|
|
912
1041
|
IndexedDBAdapter.prototype.deleteTraverse = function (relations, models, srcModel, nameSpace, deleteQueue) {
|
|
913
1042
|
var relations_1, relations_1_1, models_1, models_1_1, models_2, models_2_1;
|
|
914
|
-
var
|
|
1043
|
+
var e_11, _a, e_12, _b, e_13, _c;
|
|
915
1044
|
return __awaiter(this, void 0, void 0, function () {
|
|
916
|
-
var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, _d, model, hasOneIndex, values, recordToDelete, index, values, value, recordToDelete,
|
|
1045
|
+
var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, _d, model, hasOneIndex, values, recordToDelete, index, values, value, recordToDelete, e_12_1, model, index, keyValues, childrenArray, e_13_1, e_11_1;
|
|
917
1046
|
var _this = this;
|
|
918
1047
|
return __generator(this, function (_e) {
|
|
919
1048
|
switch (_e.label) {
|
|
@@ -997,8 +1126,8 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
997
1126
|
case 11: return [3 /*break*/, 4];
|
|
998
1127
|
case 12: return [3 /*break*/, 19];
|
|
999
1128
|
case 13:
|
|
1000
|
-
|
|
1001
|
-
|
|
1129
|
+
e_12_1 = _e.sent();
|
|
1130
|
+
e_12 = { error: e_12_1 };
|
|
1002
1131
|
return [3 /*break*/, 19];
|
|
1003
1132
|
case 14:
|
|
1004
1133
|
_e.trys.push([14, , 17, 18]);
|
|
@@ -1009,7 +1138,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1009
1138
|
_e.label = 16;
|
|
1010
1139
|
case 16: return [3 /*break*/, 18];
|
|
1011
1140
|
case 17:
|
|
1012
|
-
if (
|
|
1141
|
+
if (e_12) throw e_12.error;
|
|
1013
1142
|
return [7 /*endfinally*/];
|
|
1014
1143
|
case 18: return [7 /*endfinally*/];
|
|
1015
1144
|
case 19: return [3 /*break*/, 36];
|
|
@@ -1044,8 +1173,8 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1044
1173
|
case 25: return [3 /*break*/, 21];
|
|
1045
1174
|
case 26: return [3 /*break*/, 33];
|
|
1046
1175
|
case 27:
|
|
1047
|
-
|
|
1048
|
-
|
|
1176
|
+
e_13_1 = _e.sent();
|
|
1177
|
+
e_13 = { error: e_13_1 };
|
|
1049
1178
|
return [3 /*break*/, 33];
|
|
1050
1179
|
case 28:
|
|
1051
1180
|
_e.trys.push([28, , 31, 32]);
|
|
@@ -1056,7 +1185,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1056
1185
|
_e.label = 30;
|
|
1057
1186
|
case 30: return [3 /*break*/, 32];
|
|
1058
1187
|
case 31:
|
|
1059
|
-
if (
|
|
1188
|
+
if (e_13) throw e_13.error;
|
|
1060
1189
|
return [7 /*endfinally*/];
|
|
1061
1190
|
case 32: return [7 /*endfinally*/];
|
|
1062
1191
|
case 33: return [3 /*break*/, 36];
|
|
@@ -1067,8 +1196,8 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1067
1196
|
case 36: return [3 /*break*/, 1];
|
|
1068
1197
|
case 37: return [3 /*break*/, 44];
|
|
1069
1198
|
case 38:
|
|
1070
|
-
|
|
1071
|
-
|
|
1199
|
+
e_11_1 = _e.sent();
|
|
1200
|
+
e_11 = { error: e_11_1 };
|
|
1072
1201
|
return [3 /*break*/, 44];
|
|
1073
1202
|
case 39:
|
|
1074
1203
|
_e.trys.push([39, , 42, 43]);
|
|
@@ -1079,7 +1208,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1079
1208
|
_e.label = 41;
|
|
1080
1209
|
case 41: return [3 /*break*/, 43];
|
|
1081
1210
|
case 42:
|
|
1082
|
-
if (
|
|
1211
|
+
if (e_11) throw e_11.error;
|
|
1083
1212
|
return [7 /*endfinally*/];
|
|
1084
1213
|
case 43: return [7 /*endfinally*/];
|
|
1085
1214
|
case 44:
|
|
@@ -1115,8 +1244,8 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1115
1244
|
};
|
|
1116
1245
|
IndexedDBAdapter.prototype.batchSave = function (modelConstructor, items) {
|
|
1117
1246
|
return __awaiter(this, void 0, void 0, function () {
|
|
1118
|
-
var result, storeName, txn, store,
|
|
1119
|
-
var
|
|
1247
|
+
var result, storeName, txn, store, _loop_3, this_1, items_2, items_2_1, item, e_14_1;
|
|
1248
|
+
var e_14, _a;
|
|
1120
1249
|
var _this = this;
|
|
1121
1250
|
return __generator(this, function (_b) {
|
|
1122
1251
|
switch (_b.label) {
|
|
@@ -1131,7 +1260,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1131
1260
|
storeName = this.getStorenameForModel(modelConstructor);
|
|
1132
1261
|
txn = this.db.transaction(storeName, 'readwrite');
|
|
1133
1262
|
store = txn.store;
|
|
1134
|
-
|
|
1263
|
+
_loop_3 = function (item) {
|
|
1135
1264
|
var namespaceName, modelName, model, connectedModels, keyValues, _deleted, index, key, instance;
|
|
1136
1265
|
return __generator(this, function (_a) {
|
|
1137
1266
|
switch (_a.label) {
|
|
@@ -1180,7 +1309,7 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1180
1309
|
case 3:
|
|
1181
1310
|
if (!!items_2_1.done) return [3 /*break*/, 6];
|
|
1182
1311
|
item = items_2_1.value;
|
|
1183
|
-
return [5 /*yield**/,
|
|
1312
|
+
return [5 /*yield**/, _loop_3(item)];
|
|
1184
1313
|
case 4:
|
|
1185
1314
|
_b.sent();
|
|
1186
1315
|
_b.label = 5;
|
|
@@ -1189,14 +1318,14 @@ var IndexedDBAdapter = /** @class */ (function () {
|
|
|
1189
1318
|
return [3 /*break*/, 3];
|
|
1190
1319
|
case 6: return [3 /*break*/, 9];
|
|
1191
1320
|
case 7:
|
|
1192
|
-
|
|
1193
|
-
|
|
1321
|
+
e_14_1 = _b.sent();
|
|
1322
|
+
e_14 = { error: e_14_1 };
|
|
1194
1323
|
return [3 /*break*/, 9];
|
|
1195
1324
|
case 8:
|
|
1196
1325
|
try {
|
|
1197
1326
|
if (items_2_1 && !items_2_1.done && (_a = items_2.return)) _a.call(items_2);
|
|
1198
1327
|
}
|
|
1199
|
-
finally { if (
|
|
1328
|
+
finally { if (e_14) throw e_14.error; }
|
|
1200
1329
|
return [7 /*endfinally*/];
|
|
1201
1330
|
case 9: return [4 /*yield*/, txn.done];
|
|
1202
1331
|
case 10:
|