Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afterDelete hook (on about to be deleted object) not being called from afterDelete hook? #2939

Closed
maqen opened this issue Oct 26, 2016 · 7 comments

Comments

@maqen
Copy link

maqen commented Oct 26, 2016

I get code that deletes a child object on afterDelete

I also have a hook for afterDelete on the child for a child child but that don't seems to be called?

Parse.Cloud.afterDelete('Grandparent', (request) => {
  var query = new Parse.Query('Parent');
  query.equalTo('grandparent', request.object.id);
  query.find().then((parents) => {
    return Parse.Object.destroyAll(parents, {useMasterKey: true});
  }).then(() => console.log('Removed all parents'));
});

Parse.Cloud.afterDelete('Parent', (request) => {
  var query = new Parse.Query('Child');
  query.equalTo('parent', request.object.id);
  query.find().then((children) => {
    return Parse.Object.destroyAll(children, {useMasterKey: true});
  }).then(() => console.log('Removed all children'));
});

Removed all children will never be called?

@maqen maqen changed the title afterDelete hook (on about to be deleted object) not runned for from afterDelete? afterDelete hook (on about to be deleted object) not runned from afterDelete hook? Oct 26, 2016
@maqen maqen changed the title afterDelete hook (on about to be deleted object) not runned from afterDelete hook? afterDelete hook (on about to be deleted object) not being called from afterDelete hook? Oct 26, 2016
@flovilmart
Copy link
Contributor

Seems that you are using the wrong variable. parents vs connectors

@maqen
Copy link
Author

maqen commented Oct 26, 2016

@flovilmart thanks for spotting the example typo

Looking through logs there are no actual calls for DELETE on Child only on Parent

@flovilmart
Copy link
Contributor

how are you monitoring the logs? on a local server? output of you process?

@maqen
Copy link
Author

maqen commented Oct 26, 2016

Local server using verbose in setting up ParseServer

@flovilmart
Copy link
Contributor

flovilmart commented Oct 26, 2016

can you provide the full logs of this transaction?

@maqen
Copy link
Author

maqen commented Oct 26, 2016

So my error was passing request.object.id instead of request.object as this is a pointer field

Sorry for the inconvenience and thanks @flovilmart for trying to help out

@maqen maqen closed this as completed Oct 26, 2016
@flovilmart
Copy link
Contributor

Eheh No problem! This is mostly why we ask for the logs when reporting the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants