Skip to content

beforeSave and afterSave conflict #2938

Closed

Description

@el-mail

hello, beforeSave and afterSave parallel not worked, example

Parse.Cloud.beforeSave('TestClass', function(request, response) {   
response.success();
});

Parse.Cloud.afterSave('TestClass', function (request) { 
  if (request.object.existed()) {
    return;
  }  
      Parse.Push.send({
        where:{}, 
        data: {alert:"Push me"}
        }, { useMasterKey: true }).then(function() { 
            console.log('Sent push.');
          }, function(error) {
            throw "Push Error " + error.code + " : " + error.message;
        }); 
});


---- afterSave not worked

example only code afterSave worked


Parse.Cloud.afterSave('TestClass', function (request) { 

  if (request.object.existed()) {
    return;
  }  
      Parse.Push.send({
        where:{}, 
        data: {alert:"Push me"}
        }, { useMasterKey: true }).then(function() { 
            console.log('Sent push.');
          }, function(error) {
            throw "Push Error " + error.code + " : " + error.message;
        }); 

});

example push code on first beforeSave worked, but anyway afterSave nothing doing


Parse.Cloud.beforeSave('TestClass', function(request, response) {   
  if (request.object.existed()) {
    return;
  }  
      Parse.Push.send({
        where:{}, 
        data: {alert:"Push me"}
        }, { useMasterKey: true }).then(function() { 
                    response.success();
            console.log('Sent push.');
          }, function(error) {
            throw "Push Error " + error.code + " : " + error.message;
        }); 

});


Parse.Cloud.afterSave('TestClass', function (request) { 
var GameScore = Parse.Object.extend("GameScore");
var gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.save(null, {
  success: function(gameScore) {
    alert('New object created with objectId: ' + gameScore.id);
  },
  error: function(gameScore, error) {
    alert('Failed to create new object, with error code: ' + error.message);
  }
});
});

Not saved obj, afterSave not work

help to fix

Activity

  1. changed the title [-]beforeSave and afterSave parse conflict[/-] [+]beforeSave and afterSave conflict[/+] on Oct 26, 2016
  2. flovilmart commented on Oct 26, 2016

    @flovilmart
    Contributor

    Can you open the issue again with the full issue template filled please?

  3. el-mail commented on Oct 27, 2016

    @el-mail
    Author

    Okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions