Vins Vins - 8 months ago 88
Javascript Question

Parse server query each with useMasterKey parameter

I'm migrating from Parse to Parse server. Most of my code is made without promises.
For this to work, I have to send the parameter:

useMasterKey: true
(where necessary) for each query / save.

For find and get queries or fetch objects, I have no problems, example: (find)

success: function(results) {

Parse Server (find)

query.find({useMasterKey: true
}).then(function(results) {
//.... (fetch)

success: function(user) {

Parse Server (fetch)

user.fetch({useMasterKey: true,
success: function(user) {

The problem is with each functions: (each)

query.each(function(comment) {

Parse Server (each)

query.each({useMasterKey: true
}).then(function(comment) {

It does not work.



Although the docs don't suggest that the useMasterKey option is supported for an each query, having tested and verified myself it is in fact possible. Syntax as follows:

query.each(callback, {useMasterKey: true})

Where callback is a function that is called for each result of the query.