Reputation: 37
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.
Upvotes: 1
Views: 845
Reputation: 2098
Just change the function parameter
name or handle local comment
object assignment. Check if it works after.
Upvotes: 1