I have a function that creates a new Comment object and saves it to the database. Before saving it the comment text, the id of the object it is attached to, as well as a pointer to the user object that posted the comment are set on the object before it is saved. However when run I get the error:
Cannot create pointer to unsaved parse object
Here is the code in question:
this.postComment = function(comment, objectId) {
// Get logged in user
var currentUser = Parse.User.current();
// extend and create new Comment object
var Comment = Parse.Object.extend('Comment');
var comment = new Comment();
// Set fields to be saved
comment.set('object', objectId);
comment.set('commentText', comment);
comment.set('user', currentUser);
// Save new comment to db
comment.save(null, {
success: function(comment) {
console.log("success");
},
error: function(comment, error) {
console.log(error);
}
});
}
This leads me to believe that there is something wrong with the User object that I am pointing to but the User exists in the database and is even retrieved using Parse.User.current()
I've looked at other posts with the same error but I have yet to find a solution to this problem. Please let me know if there is any more information I can provide.
commentto function andparameterpassed to function are named same and assignment is done withset. Check what value is coming in debugger for comment object inside function duringsetstatements. Change the parameter first for function definition and try.