Vins Vins - 1 year ago 140
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.


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download