@aws-amplify/datastore 3.7.4-custom-pk.96 → 3.7.4-custom-pk.97
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/aws-amplify-datastore.js +27 -29
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +1 -1
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.js +33 -32
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +33 -32
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/package.json +7 -7
- package/src/storage/adapter/IndexedDBAdapter.ts +59 -57
|
@@ -89273,7 +89273,7 @@ function () {
|
|
|
89273
89273
|
var e_9, _a, e_10, _b, e_11, _c;
|
|
89274
89274
|
|
|
89275
89275
|
return __awaiter(this, void 0, void 0, function () {
|
|
89276
|
-
var rel, relationType,
|
|
89276
|
+
var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, _d, model, hasOneIndex, values, recordToDelete, index, values, value, recordToDelete, e_10_1, model, index, keyValues, childrenArray, e_11_1, e_9_1;
|
|
89277
89277
|
|
|
89278
89278
|
var _this = this;
|
|
89279
89279
|
|
|
@@ -89295,12 +89295,8 @@ function () {
|
|
|
89295
89295
|
/*break*/
|
|
89296
89296
|
, 37];
|
|
89297
89297
|
rel = relations_2_1.value;
|
|
89298
|
-
relationType = rel.relationType,
|
|
89298
|
+
relationType = rel.relationType, modelName = rel.modelName, targetName = rel.targetName, targetNames = rel.targetNames, associatedWith = rel.associatedWith;
|
|
89299
89299
|
storeName = this.getStorename(nameSpace, modelName);
|
|
89300
|
-
index = Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel) || // if we were unable to find an index via relationTypes
|
|
89301
|
-
// i.e. for keyName connections, attempt to find one by the
|
|
89302
|
-
// associatedWith property
|
|
89303
|
-
Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndexFromAssociation"])(this.schema.namespaces[nameSpace].relationships[modelName].indexes, rel.associatedWith);
|
|
89304
89300
|
_d = relationType;
|
|
89305
89301
|
|
|
89306
89302
|
switch (_d) {
|
|
@@ -89340,26 +89336,13 @@ function () {
|
|
|
89340
89336
|
/*break*/
|
|
89341
89337
|
, 12];
|
|
89342
89338
|
model = models_1_1.value;
|
|
89343
|
-
hasOneIndex =
|
|
89344
|
-
if (!(targetNames
|
|
89339
|
+
hasOneIndex = 'byPk';
|
|
89340
|
+
if (!(targetNames === null || targetNames === void 0 ? void 0 : targetNames.length)) return [3
|
|
89345
89341
|
/*break*/
|
|
89346
89342
|
, 8];
|
|
89347
|
-
|
|
89348
|
-
return model
|
|
89343
|
+
values = targetNames.map(function (targetName) {
|
|
89344
|
+
return model[targetName];
|
|
89349
89345
|
});
|
|
89350
|
-
keyValues = this.getIndexKeyValues(model);
|
|
89351
|
-
values = [];
|
|
89352
|
-
|
|
89353
|
-
if (hasConnectedModelFields) {
|
|
89354
|
-
// Values will be that of the child model
|
|
89355
|
-
values = targetNames.map(function (targetName) {
|
|
89356
|
-
return model[targetName];
|
|
89357
|
-
});
|
|
89358
|
-
} else {
|
|
89359
|
-
// values will be that of the parent model
|
|
89360
|
-
values = keyValues;
|
|
89361
|
-
}
|
|
89362
|
-
|
|
89363
89346
|
if (values.length === 0) return [3
|
|
89364
89347
|
/*break*/
|
|
89365
89348
|
, 12];
|
|
@@ -89381,16 +89364,28 @@ function () {
|
|
|
89381
89364
|
, 12];
|
|
89382
89365
|
|
|
89383
89366
|
case 8:
|
|
89384
|
-
|
|
89385
|
-
|
|
89386
|
-
|
|
89387
|
-
|
|
89388
|
-
|
|
89367
|
+
index = void 0;
|
|
89368
|
+
values = void 0;
|
|
89369
|
+
|
|
89370
|
+
if (targetName && targetName in model) {
|
|
89371
|
+
index = hasOneIndex;
|
|
89372
|
+
value = model[targetName];
|
|
89373
|
+
values = [value];
|
|
89374
|
+
} else {
|
|
89375
|
+
// backwards compatability for older versions of codegen that did not emit targetName for HAS_ONE relations
|
|
89376
|
+
// TODO: can we deprecate this? it's been ~2 years since codegen started including targetName for HAS_ONE
|
|
89377
|
+
// If we deprecate, we'll need to re-gen the MIPR in __tests__/schema.ts > newSchema
|
|
89378
|
+
// otherwise some unit tests will fail
|
|
89379
|
+
index = Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel);
|
|
89380
|
+
values = this.getIndexKeyValues(model);
|
|
89381
|
+
}
|
|
89382
|
+
|
|
89383
|
+
if (!values || !index) return [3
|
|
89389
89384
|
/*break*/
|
|
89390
89385
|
, 12];
|
|
89391
89386
|
return [4
|
|
89392
89387
|
/*yield*/
|
|
89393
|
-
, this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(
|
|
89388
|
+
, this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(index).get(values)];
|
|
89394
89389
|
|
|
89395
89390
|
case 9:
|
|
89396
89391
|
recordToDelete = _e.sent();
|
|
@@ -89474,6 +89469,9 @@ function () {
|
|
|
89474
89469
|
/*break*/
|
|
89475
89470
|
, 26];
|
|
89476
89471
|
model = models_2_1.value;
|
|
89472
|
+
index = // explicit bi-directional @hasMany and @manyToMany
|
|
89473
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel) || // uni and/or implicit @hasMany
|
|
89474
|
+
Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndexFromAssociation"])(this.schema.namespaces[nameSpace].relationships[modelName].indexes, associatedWith);
|
|
89477
89475
|
keyValues = this.getIndexKeyValues(model);
|
|
89478
89476
|
return [4
|
|
89479
89477
|
/*yield*/
|