0

I have class and know row ID, try update this row how it's showed in this topic

https://parse.com/questions/updating-a-field-without-retrieving-the-object-first

    var Point = Parse.Object.extend("items");
    var point = new Point();
    point.id = "L8bc5utrVD";

    // Set a new value on quantity
    point.set("title", "new title");

    // Save
    point.save(null, {
      success: function(point) {
        // Saved successfully.
      },
      error: function(point, error) {
        // The save failed.
        // error is a Parse.Error with an error code and description.
        console.log('Failed to create new object, with error code: ' + error.message);
      }
});

but get error "Failed to create new object, with error code: have this item"

2 Answers 2

1

When point is created with new, it is not yet in sync. Fetching the model before saving it will resolve the issue.

Using promises:

var Point = Parse.Object.extend("items");
var point = new Point();
point.id = "L8bc5utrVD";

point.fetch() // returns a promise
.then(function(){
    point.set("title", "new title");
    return point.save(); // returns a promise
})
.then(successCallback, failCallback);
Sign up to request clarification or add additional context in comments.

Comments

0

Thanks, but problem was in Parse.Cloud.beforeSave function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.