@aws-amplify/datastore 3.7.4-custom-pk.89 → 3.7.4-custom-pk.94
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 +26 -5
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +2 -2
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +14 -1
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/util.d.ts +3 -1
- package/lib/util.js +7 -3
- package/lib/util.js.map +1 -1
- package/lib-esm/datastore/datastore.js +14 -1
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/util.d.ts +3 -1
- package/lib-esm/util.js +7 -3
- package/lib-esm/util.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +22 -0
- package/src/util.ts +13 -4
|
@@ -82863,7 +82863,7 @@ function () {
|
|
|
82863
82863
|
|
|
82864
82864
|
this.query = function (modelConstructor, identifierOrCriteria, paginationProducer) {
|
|
82865
82865
|
return __awaiter(_this, void 0, void 0, function () {
|
|
82866
|
-
var msg, modelDefinition, keyFields, predicate, pagination, result, returnOne;
|
|
82866
|
+
var msg, modelDefinition, keyFields, predicate, msg, pagination, result, returnOne;
|
|
82867
82867
|
return __generator(this, function (_a) {
|
|
82868
82868
|
switch (_a.label) {
|
|
82869
82869
|
case 0:
|
|
@@ -82893,6 +82893,14 @@ function () {
|
|
|
82893
82893
|
keyFields = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition);
|
|
82894
82894
|
|
|
82895
82895
|
if (isQueryOne(identifierOrCriteria)) {
|
|
82896
|
+
if (keyFields.length > 1) {
|
|
82897
|
+
msg = _util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].queryByPkWithCompositeKeyPresent;
|
|
82898
|
+
logger.error(msg, {
|
|
82899
|
+
keyFields: keyFields
|
|
82900
|
+
});
|
|
82901
|
+
throw new Error(msg);
|
|
82902
|
+
}
|
|
82903
|
+
|
|
82896
82904
|
predicate = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].createForSingleField(modelDefinition, keyFields[0], identifierOrCriteria);
|
|
82897
82905
|
} else {
|
|
82898
82906
|
// Object is being queried using object literal syntax
|
|
@@ -83165,6 +83173,15 @@ function () {
|
|
|
83165
83173
|
});
|
|
83166
83174
|
throw new Error(msg);
|
|
83167
83175
|
}
|
|
83176
|
+
} // observe should not accept object literal syntax
|
|
83177
|
+
|
|
83178
|
+
|
|
83179
|
+
if (identifierOrCriteria && modelConstructor && Object(_types__WEBPACK_IMPORTED_MODULE_11__["isIdentifierObject"])(identifierOrCriteria, getModelDefinition(modelConstructor))) {
|
|
83180
|
+
var msg = _util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].observeWithObjectLiteral;
|
|
83181
|
+
logger.error(msg, {
|
|
83182
|
+
objectLiteral: identifierOrCriteria
|
|
83183
|
+
});
|
|
83184
|
+
throw new Error(msg);
|
|
83168
83185
|
}
|
|
83169
83186
|
|
|
83170
83187
|
if (identifierOrCriteria !== undefined && modelConstructor === undefined) {
|
|
@@ -97494,7 +97511,9 @@ var __values = undefined && undefined.__values || function (o) {
|
|
|
97494
97511
|
|
|
97495
97512
|
var ID = 'id';
|
|
97496
97513
|
var errorMessages = {
|
|
97497
|
-
idEmptyString: 'An index field cannot contain an empty string value'
|
|
97514
|
+
idEmptyString: 'An index field cannot contain an empty string value',
|
|
97515
|
+
queryByPkWithCompositeKeyPresent: 'Models with composite primary keys cannot by queried by a single key value. Use object literal syntax for composite keys instead: https://docs.amplify.aws/lib/datastore/advanced-workflows/q/platform/js/#querying-records-with-custom-primary-keys',
|
|
97516
|
+
observeWithObjectLiteral: 'Object literal syntax cannot be used with observe. Use a predicate instead: https://docs.amplify.aws/lib/datastore/data-access/q/platform/js/#predicates'
|
|
97498
97517
|
};
|
|
97499
97518
|
function extractKeyIfExists(modelDefinition) {
|
|
97500
97519
|
var _c;
|
|
@@ -97979,13 +97998,15 @@ var traverseModel = function traverseModel(srcModelName, instance, namespace, mo
|
|
|
97979
97998
|
return result;
|
|
97980
97999
|
};
|
|
97981
98000
|
var getIndex = function getIndex(rel, src) {
|
|
97982
|
-
var
|
|
98001
|
+
var indexName;
|
|
97983
98002
|
rel.some(function (relItem) {
|
|
97984
98003
|
if (relItem.modelName === src) {
|
|
97985
|
-
|
|
98004
|
+
var targetNames = extractTargetNamesFromSrc(relItem);
|
|
98005
|
+
indexName = targetNames && indexNameFromKeys(targetNames);
|
|
98006
|
+
return true;
|
|
97986
98007
|
}
|
|
97987
98008
|
});
|
|
97988
|
-
return
|
|
98009
|
+
return indexName;
|
|
97989
98010
|
};
|
|
97990
98011
|
var getIndexFromAssociation = function getIndexFromAssociation(indexes, src) {
|
|
97991
98012
|
var indexName;
|