dreamer.psp
dreamer.psp

Reputation: 615

Incrementing a field in a Parse Object. Result: TypeError: Object [object Object] has no method 'Increment'

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'

Upvotes: 0

Views: 474

Answers (1)

hhanesand
hhanesand

Reputation: 1000

Pretty sure that it's increment and not Increment.

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

Upvotes: 1

Related Questions