@aws-amplify/datastore 3.6.0 → 3.6.2-unstable.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.6.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.6.0...@aws-amplify/datastore@3.6.1) (2021-11-16)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/datastore
9
+
10
+
11
+
12
+
13
+
6
14
  # [3.6.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.5.2...@aws-amplify/datastore@3.6.0) (2021-11-12)
7
15
 
8
16
 
@@ -70458,7 +70458,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
70458
70458
  __webpack_require__.r(__webpack_exports__);
70459
70459
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
70460
70460
  // generated by genversion
70461
- var version = '4.3.5';
70461
+ var version = '4.3.7';
70462
70462
 
70463
70463
  /***/ }),
70464
70464
 
@@ -83622,7 +83622,7 @@ function () {
83622
83622
  var e_2, _a, e_3, _b, e_4, _c;
83623
83623
 
83624
83624
  return __awaiter(this, void 0, void 0, function () {
83625
- var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, relationType, storeName, modelConstructor_1, _d, recordItem, connectionRecord, e_3_1, recordItem, connectionRecord, e_4_1, e_2_1;
83625
+ var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, relationType, storeName, modelConstructor_1, _d, recordItem, getByfield, connectionRecord, e_3_1, recordItem, connectionRecord, e_4_1, e_2_1;
83626
83626
 
83627
83627
  var _this = this;
83628
83628
 
@@ -83705,12 +83705,13 @@ function () {
83705
83705
  /*break*/
83706
83706
  , 9];
83707
83707
  recordItem = records_1_1.value;
83708
- if (!recordItem[fieldName]) return [3
83708
+ getByfield = recordItem[targetName] ? targetName : fieldName;
83709
+ if (!recordItem[getByfield]) return [3
83709
83710
  /*break*/
83710
- , 8];
83711
+ , 9];
83711
83712
  return [4
83712
83713
  /*yield*/
83713
- , this.db.get(recordItem[fieldName], storeName)];
83714
+ , this.db.get(recordItem[getByfield], storeName)];
83714
83715
 
83715
83716
  case 7:
83716
83717
  connectionRecord = _e.sent();
@@ -84547,6 +84548,9 @@ function () {
84547
84548
  hasOneIndex = index || 'byId';
84548
84549
  hasOneCustomField = targetName in model;
84549
84550
  value = hasOneCustomField ? model[targetName] : model.id;
84551
+ if (!value) return [3
84552
+ /*break*/
84553
+ , 9];
84550
84554
  return [4
84551
84555
  /*yield*/
84552
84556
  , this.db.getAll(storeName)];
@@ -86740,7 +86744,7 @@ function () {
86740
86744
  var e_3, _a, e_4, _b, e_5, _c;
86741
86745
 
86742
86746
  return __awaiter(this, void 0, void 0, function () {
86743
- var namespace, relations, connectionStoreNames, modelConstructor, tx, relations_1, relations_1_1, relation, fieldName, modelName, targetName, storeName, store, modelConstructor_1, _d, recordItem, connectionRecord, e_4_1, recordItem, connectionRecord, e_5_1, e_3_1;
86747
+ var namespace, relations, connectionStoreNames, modelConstructor, tx, relations_1, relations_1_1, relation, fieldName, modelName, targetName, storeName, store, modelConstructor_1, _d, recordItem, getByfield, connectionRecord, e_4_1, recordItem, connectionRecord, e_5_1, e_3_1;
86744
86748
 
86745
86749
  var _this = this;
86746
86750
 
@@ -86825,12 +86829,13 @@ function () {
86825
86829
  /*break*/
86826
86830
  , 9];
86827
86831
  recordItem = records_1_1.value;
86828
- if (!recordItem[fieldName]) return [3
86832
+ getByfield = recordItem[targetName] ? targetName : fieldName;
86833
+ if (!recordItem[getByfield]) return [3
86829
86834
  /*break*/
86830
- , 8];
86835
+ , 9];
86831
86836
  return [4
86832
86837
  /*yield*/
86833
- , this._get(store, recordItem[fieldName])];
86838
+ , this._get(store, recordItem[getByfield])];
86834
86839
 
86835
86840
  case 7:
86836
86841
  connectionRecord = _e.sent();
@@ -87811,6 +87816,9 @@ function () {
87811
87816
  hasOneIndex = index || 'byId';
87812
87817
  hasOneCustomField = targetName in model;
87813
87818
  value = hasOneCustomField ? model[targetName] : model.id;
87819
+ if (!value) return [3
87820
+ /*break*/
87821
+ , 9];
87814
87822
  return [4
87815
87823
  /*yield*/
87816
87824
  , this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(hasOneIndex).get(value)];
@@ -95565,15 +95573,26 @@ var traverseModel = function traverseModel(srcModelName, instance, namespace, mo
95565
95573
 
95566
95574
  try {
95567
95575
  modelInstance = modelInstanceCreator(modelConstructor, instance[rItem.fieldName]);
95568
- } catch (error) {// Do nothing
95576
+ } catch (error) {
95577
+ // Do nothing
95578
+ console.log(error);
95569
95579
  }
95570
95580
 
95571
95581
  result.push({
95572
95582
  modelName: rItem.modelName,
95573
95583
  item: instance[rItem.fieldName],
95574
95584
  instance: modelInstance
95575
- });
95576
- draftInstance[rItem.fieldName] = draftInstance[rItem.fieldName].id;
95585
+ }); // targetName will be defined for Has One if feature flag
95586
+ // https://docs.amplify.aws/cli/reference/feature-flags/#useAppsyncModelgenPlugin
95587
+ // is true (default as of 5/7/21)
95588
+ // Making this conditional for backward-compatibility
95589
+
95590
+ if (rItem.targetName) {
95591
+ draftInstance[rItem.targetName] = draftInstance[rItem.fieldName].id;
95592
+ delete draftInstance[rItem.fieldName];
95593
+ } else {
95594
+ draftInstance[rItem.fieldName] = draftInstance[rItem.fieldName].id;
95595
+ }
95577
95596
  }
95578
95597
 
95579
95598
  break;