Parse.Cloud.afterSave is not a function

I am playing around with a parse app (JS code base).
I am trying to count relations from Category to Idea on the field category.ideas and store the number to category.ideacount.

var Idea = Parse.Object.extend('Idea');
Parse.Cloud.afterSave(Idea, function(request) {
  query = new Parse.Query("Idea");
  query.get(request.object.get("subject").id, {
    success: function(category) {
      category.increment("ideacount");
      category.save();
    },
    error: function(error) {
      console.error("Got an error " + error.code + " : " + error.message);
    }
  });
});

i have placed this in my app.js right after initializing Parse.

The error i get (JS console):

Uncaught TypeError: Parse.Cloud.afterSave is not a function

Any idea how to fix this?


Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.