You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parse.Cloud.beforeDelete("Album", (request) => {
const query = new Parse.Query("Photo");
query.equalTo("album", request.object);
query.count()
.then((count) => {
if (count > 0) {
throw "Can't delete album if it still has photos.";
})
.catch((error) {
throw "Error " + error.code + " : " + error.message + " when getting photo count.";
});
});
And states:
If the function throws, the Album object will not be deleted, and the client will get an error. Otherwise, the object will be deleted normally.
-The function isn't async, or doesn't return a promise.
-Syntax error after the first throw (no closing bracked)
-Syntax error after .catch (no =>)
-Catching the first error will return 'Error undefined : undefined when getting photo count.'
I might be wrong, but wouldn't the delete happen prior to the error throwing?
Can you propose a solution?
What changes do you think should be made? Have you considered multiple solutions? Will this be suitable for all use cases?
Parse.Cloud.beforeDelete("Album", (request) => {
const query = new Parse.Query("Photo");
query.equalTo("album", request.object);
return query.count()
.then((count) => {
if (count > 0) {
throw "Can't delete album if it still has photos.";
}
})
});
or
Parse.Cloud.beforeDelete("Album", async (request) => {
const query = new Parse.Query("Photo");
query.equalTo("album", request.object);
const count = await query.count()
if (count > 0) {
throw "Can't delete album if it still has photos.";
}
});
The text was updated successfully, but these errors were encountered:
Link to section:
https://docs.parseplatform.org/cloudcode/guide/#delete-triggers
What is the issue?
The example is:
And states:
If the function throws, the Album object will not be deleted, and the client will get an error. Otherwise, the object will be deleted normally.
-The function isn't async, or doesn't return a promise.
-Syntax error after the first throw (no closing bracked)
-Syntax error after .catch (no =>)
-Catching the first error will return 'Error undefined : undefined when getting photo count.'
I might be wrong, but wouldn't the delete happen prior to the error throwing?
Can you propose a solution?
What changes do you think should be made? Have you considered multiple solutions? Will this be suitable for all use cases?
or
The text was updated successfully, but these errors were encountered: