-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Description
Is your feature request related to a problem? Please describe.
Right now, we still rely on the legacy backbone style success / error callback methods. With node.js moving forward at an incredible pace, I believe it's time to make the cloud functions enter the 21st century supporting async / await, promises and more
Describe the solution you'd like
- Support promises, async/await in cloud code as valid return values for hooks and functions
- Mark calls to success / error callbacks deprecated in Cloud Code (with a big fat warning)
- Later on, remove success / error implementations
Cloud funcitons would look like:
Parse.Cloud.beforeSave('ClassName', async ({ object }) => {
await doSomething();
if (somethingsFishy(object)) {
throw new Error('OOps')
}
return;
});
// Also valid
Parse.Cloud.beforeSave('ClassName', async ({ object }) => {
await doSomething();
if (somethingsFishy(object)) {
return new Error('OOps'); // returning an error is also allowed
}
});
For functions:
Parse.Cloud.define('MyFunction', async ({ params }) => {
await doSomething();
if (!param.isValid) {
return new Error('OOps'); // returning an error is also allowed
}
return 'OK!';
});
cleever and mtrezza
Metadata
Metadata
Assignees
Labels
No labels