As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
I want to store links using the relational stuff with Kinvey. Saving a single link with the following works just fine, but it fails when I pass an array into it. According to the docs, this should work? ("This includes embedding references in array-valued properties.")
Code:
var updatedTopic = {
_id: $scope.topic._id,
name: $scope.topic.name,
day_offset: $scope.topic.day_offset,
kickstart_id: $scope.topic.kickstart_id,
overview: $scope.topic.overview,
topic_tpl_id: $scope.topic.topic_tpl_id,
files: $scope.topic.files,
links: $scope.topic.links (an array with one object, this works ... but fails with multiples)
};
// save the updated topic with the updated link
$kinvey.DataStore.save('topics', updatedTopic, {
relations : { links: 'topic-links' }
}).then(function(response) {
console.log(response);
})
When I pull down topic, it contains the embedded references to links properly (when there's only one entry in the array).
Do I need to iterate over my array and do API calls for each one? Also, is there a way to save an entity without have to "re-save" all of the properties?
{"error":"KinveyInternalErrorRetry","description":"The Kinvey server encountered an unexpected error. Please retry your request","debug":"This operation does not support using both operators (beginning with a $) and non-operators at the same time. Please include either only operators or only non-operators in your request and try again."}
Also, can we get a better code formatting option?
O
OhmzTech
said
about 9 years ago
Can you provide the output of $scope.topic.liinks? I believe this should work just fine, but I'm guessing the array of objects you think is being sent isn't being sent quite right. I would try taking that array and turning it into a JSON string, see how it looks and include that here.
Also, are you just having a problem saving or fetching too? Try creating the kinveyRef array in the API console, and then fetch it from your application.
D
Dave Ackerman
said
about 9 years ago
Here's the JSON.stringify($scope.topics.links):
https://gist.github.com/dmackerman/9843012
The first object is a KinveyRef that was successfully saved. Is it the $$hashKey things?
D
Dave Ackerman
said
about 9 years ago
Fetching works fine for one object, but not for multiples.
O
OhmzTech
said
about 9 years ago
Yes, try renaming those fields without the $$.
D
Dave Ackerman
said
about 9 years ago
Yep, that was it. Just for future reference for peeps using angular.
links: angular.copy($scope.topic.links) // get rid of $$hashKey before saving relational data.
M
Mark
said
about 9 years ago
Yes, we are aware of the `$$hashKey` problems, for now it is best to strip them out yourself before saving, as you already figured out.
J
JTLai
said
about 9 years ago
Thanks for sharing your answer Dave! Solved the problem for me as well.
Mark, you guys prob know this already, that there is a built-in JSON stringify function in Angular: https://docs.angularjs.org/api/ng/function/angular.toJson
This will clean up the $$hashkey used by Angular. In case you guys are thinking about patching the official Kinvey Angular library.
M
Mark
said
about 9 years ago
Yes, the [latest version](http://devcenter.kinvey.com/angular/downloads) of the angular library now uses the built-in stringifier, so you no longer should run into this.
Dave Ackerman
topic: {
links: [ { ... } ]
}
I want to store links using the relational stuff with Kinvey. Saving a single link with the following works just fine, but it fails when I pass an array into it. According to the docs, this should work? ("This includes embedding references in array-valued properties.")
Code:
var updatedTopic = {
_id: $scope.topic._id,
name: $scope.topic.name,
day_offset: $scope.topic.day_offset,
kickstart_id: $scope.topic.kickstart_id,
overview: $scope.topic.overview,
topic_tpl_id: $scope.topic.topic_tpl_id,
files: $scope.topic.files,
links: $scope.topic.links (an array with one object, this works ... but fails with multiples)
};
// save the updated topic with the updated link
$kinvey.DataStore.save('topics', updatedTopic, {
relations : { links: 'topic-links' }
}).then(function(response) {
console.log(response);
})
When I pull down topic, it contains the embedded references to links properly (when there's only one entry in the array).
Do I need to iterate over my array and do API calls for each one? Also, is there a way to save an entity without have to "re-save" all of the properties?