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

cloud code query.each() useMasterKey:true #3401

Closed
BarryWood34 opened this issue Jan 19, 2017 · 4 comments
Closed

cloud code query.each() useMasterKey:true #3401

BarryWood34 opened this issue Jan 19, 2017 · 4 comments

Comments

@BarryWood34
Copy link

I'm using query.each() in my cloud code and am struggling to make it work with useMasterKey:true. error returned is "Error=Permission denied for action find on class ..."

Logging suggests my problem lies in the query.each() function

What is the correct syntax for using useMasterKey:true with query.each?

I've got other examples working such as ...

 object.save(null,{useMasterKey:true})

and

query.find({useMasterKey:true,success:...

Here's the outline of the code with some of the detail commented out.

thanks in advance...

query3.each(
                                                        
    function(object){
    ...
    object.save(null,{useMasterKey:true})
    },
    {
    success: function() {
    ...
    response.success("OK");
    },
    error: function(error) {
    ...
    response.error("Failed");
    }
    }, {useMasterKey: true});
    
@flovilmart
Copy link
Contributor

Put use useMasterKey in the same object as the error and success.

@BarryWood34
Copy link
Author

Thanks for the quick response, Please can you give me an example using the code snippet above?

@flovilmart
Copy link
Contributor

query3.each(
                                                        
    function(object){
    ...
    object.save(null,{useMasterKey:true})
    },
    {
    success: function() {
    ...
    response.success("OK");
    },
    error: function(error) {
    ...
    response.error("Failed");
    }
    , useMasterKey: true});
    

@BarryWood34
Copy link
Author

Great thank you !

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