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 Cloud Code works on Parse.com but not Parse Server #127

Closed
Daniel-Higgott opened this issue Mar 23, 2016 · 1 comment
Closed

Comments

@Daniel-Higgott
Copy link

Hello!

Sorry if this is in the wrong place, please delete if it is. Fairly new developer here. I'm developing an iOS app which hasn't been released yet. I started on Parse.com and created a Parse Server install on Heroku with MLabs. My issue is I have a afterDelete hook in Cloud Code which works on my Parse.com app, but doesn't do anything on the Parse Server code. I have other cloud code function that still work, so cloud code generally is still running. Can anyone see anything obvious I am doing wrong, or could anyone suggest something I need to check outside my Cloud Code to explain this behaviour?

Here is my code:

Parse.Cloud.afterDelete("Lists", function(request) {
    var query = new Parse.Query("Posts");
    query.equalTo("listObjectId", request.object.id);
    query.find({
        success: function(posts) {
            Parse.Object.destroyAll(posts, {
                success: function() {
                }
            })
        }
    })
});

Thanks so much in advance!

Dan

@Daniel-Higgott
Copy link
Author

Ah-ha!

I seem to have solved this. It seems you need to call useMasterkey inside the destroyAll function now. This now closed issue was helpful.

I also defined my server URL at the top of my cloud code, but I haven't experimented to see if this was necessary yet. For anyone interested my working code is:

Parse.Cloud.afterDelete("Lists", function(request) {
    var query = new Parse.Query("Posts");
    query.equalTo("listObjectId", request.object.id);
    query.find({
        success: function(posts) {
          Parse.Cloud.useMasterKey();
            Parse.Object.destroyAll(posts, {
                success: function() {
                }
            })
        }
    })
});

Hope that helps someone!

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

1 participant