0

Within "afterSave" method in Parse, I want to increment a field in a Parse Object. I get the object and increment in the following way:

Parse.Cloud.afterSave("Activity", function(request) {

if(request.object.get("type") == "joinedGame") {
   var aGameObject = request.object.get("toGameR");
   var gameRQuery = new Parse.Query("GameR");
   gameRQuery.get(aGameObject, {
         success: function (obj) {
              obj.Increment("numberOfPlayers");
              obj.save();
            },
            error: function(error) {
                   console.log("Failed: " +error.message);
            }
     });
  }

This code increments "numberOfPlayers" field as many times as the "afterSave" function gets called and the first "if" statement holds true. "obj" is also saved. Incremented "numberOfPlayers" field is shown in the Parse DB. However, Parse log shows the following error:

Result: TypeError: Object [object Object] has no method 'Increment'

1 Answer 1

1

Pretty sure that it's increment and not Increment.

Here's an example in which Parse does something similar.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! It worked. For some reason, Xcode suggests "Increment" and not "increment".

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.