Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse server query each with useMasterKey parameter

Tags:

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:

Parse.com (find)

query.find({
    success: function(results) {
    //...

Parse Server (find)

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

Parse.com (fetch)

user.fetch({
    success: function(user) {
    //...

Parse Server (fetch)

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

The problem is with each functions:

Parse.com (each)

query.each(function(comment) {
    //...

Parse Server (each)

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

It does not work.

Thanks

like image 376
Vins Avatar asked May 06 '16 15:05

Vins


People also ask

What is a parse query?

Parsing of a query is the process by which this decision making is done that for a given query, calculating how many different ways there are in which the query can run. Every query must be parsed at least once. The parsing of a query is performed within the database using the Optimizer component.

What is parse server used for?

The sole purpose of Parse was to demystify the process of backend development. Launched in February 2016, Parse Server is an open source version of Parse (MBaaS platform) which was originally developed by Parse Inc. It can be deployed to any infrastructure that can run node. js.

What is parse server in node JS?

Parse Server is an open source backend that can be deployed to any infrastructure that can run Node. js. You can find the source on the GitHub repo. Parse Server uses MongoDB or PostgreSQL as a database. You can deploy and run Parse Server on your own infrastructure.


1 Answers

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.

like image 57
HorseloverFat Avatar answered Sep 28 '22 02:09

HorseloverFat