Start a new topic

Saving nested Kinvey References in Array Field

I have a data model defined where I have nested references within an array list. I am trying to update the array on the primary object, and at the same time create the sub objects. I can't seem to determine the correct syntax for the referenced objects. Here is my code:

function saveNewCommentForTip(options) {

var u = Kinvey.getActiveUser();

var promise = Kinvey.DataStore.get("Tips", options.tip_id, {

relations: {comments: 'comments'},

success: function(thisTip){

var c = {

text: options.text,

tip: thisTip,

user: u


if (thisTip.comments) {


} else {

thisTip.comments = [c];


var promise ="Tips", thisTip, {

relations : { comments: 'comments', 'comment.user': 'user', 'comment.tip': 'Tips' }



function(tip) {


options.success && options.success(tip);


function (error) {

alert("Error saving tip/comment");




error: function(error) {

alert("Error loading tip while saving comment");





When this completes, I can verify that the tips entity is udpated with a complete array of KinveyRef entities, and the "comments" are created, however the tip and user fields are copies of the relation objects rather than KinveyRef objects. I feel like I am probably missing something obvious in the relations configuration of the save() method, but I've tried many different options. Thanks in advance.

1 Comment

References embedded into array elements are not supported. The array element itself can be a reference, but cannot have nested references.

In your case, this means `comment.user` and `comment.tip` will just be copies of the relation objects.
Login or Signup to post a comment