Announcing Parse Server 4.4

Parse Platform nurtures a vibrant open source community reaching +33K stars on Github’s official repo. According to npm, the number of Parse Server installations grew up over 50% in the last 12 months and reached over 30K per week. Parse Javascript SDK installations are already +100K per week, growing up over 50% in the previous 12 months.

Today we are pleased to announce that the most recent Parse Server version, the 4.4, is available on Back4App ( How to upgrade Parse Server). This is a big release with a new cloud code validation feature, a new afterLiveQueryEvent trigger, and fixes/improvements on GraphQL API, security, auth, and more. For a detailed change list, please visit the repo release page.

On the next topics, I’m going to deep dive into some of those changes showing practical examples.

Cloud Code Validators

Suppose you need to retrieve all Dogs older than a certain age. The attribute age is mandatory because you need a limited age to retrieve records above that given value. If no value is provided, you cannot determine which dogs are older. So, to ensure the age parameter is sent in, use this example:

The same logic can be used if you need to ensure more than one parameter is sent. In this example, we will retrieve dogs between two ages, so, logically, you will need to have two values passed the minimumAge and the maximumAge. Parse Cloud Code Validators support multiple parameters to ensure all are met, or the code will not run.

Sometimes you need more complex validation. For those cases, validators allow you to write business logic that will validate (or not) any given parameter. If your validation code returns true, it will consider the parameter as valid. If false, it will consider your parameter invalid. In this example, we will try to find all dogs belong to a specific owner. We need to ensure a name parameter is given (required), and also, it has a certain length, as "A" is just not a valid name.
Let's consider 3 as the minimum length for a name (as Joe, for instance).
The parameter "owner" will be a String, it is required (or the code won't run), the options are the javascript code that will validate the parameter, so let's return TRUE if its length is 3 or more.

If you want more details about the Validation please check the official Parse Platform documentation.

After Live Query Event

For instance, let’s say you have a Dog class and when creating a new Dog, that object must have its name property set to Fido. Also, when updating an existing Dog, that object must have its name property set to Rex. You could use the Cloud Code below to achieve that functionality:

You must remember that Live Queries are meant to deliver real-time data to the clients, so, you have to make sure all Cloud Code inside that Event is very efficient and as fast as it can be, otherwise, clients will experience delays in data delivery, as the Live Query events will NOT be triggered until the afterLiveQueryEvent has finished running.

Other Cloud Code Improvements

SkipWithMasterkey

Improvements on Logs

Duplicated functions

Warning: Duplicate cloud functions exist for trigger beforeSave on class TestObject. The first will be ignored.

Detailed Error Stack

For the following code:

You’ll see the Log Error below:

error: Parse error: yolo is not defined {"code":141,"stack":"ReferenceError: yolo is not defined at /cloud/main.js:3:5 at /node_modules/parse-server/lib/Routers/FunctionsRouter.js:199:16 at processTicksAndRejections (internal/process/task_queues.js:93:5)"}

If you don’t know how to use the latest version please check our guide here.

Originally published at https://blog.back4app.com on November 20, 2020.

Store and query relational data on the cloud. Make it accessible over GraphQL and REST with a scalable, open-source backend, based on the Parse Platform.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store