Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parse.Cloud.afterLiveQueryEvent('DogObject', async (request) => {
if (request.event == "Create") {
// If I am creating a new Dog
const thisDog = request.object;
thisDog.set('name', 'Fido'); // Set its name to Fido
} else if (request.event == "update") {
// Else, if I am Updating an existing Dog
const thisDog = request.object;
thisDog.set('name', 'Rex'); // Set its name to Rex
} else {
// Otherwise, do nothing
return;
}
});
@dblythy

This comment has been minimized.

Copy link

@dblythy dblythy commented Nov 24, 2020

} else if (request.event == "update") {

Related to this issue in the Parse Server repo, at the moment, request.event needs to contain a capitalized first letter. So this should be request.event == 'Update'.

   // Otherwise, do nothing
   return;

These lines here will do nothing, unless there is more below obviously, but it won't prevent the event from firing. If your intention is to do nothing on the client side too by preventing the event from firing, you can use:

    } else {
        // Otherwise, do nothing
        request.sendEvent = false;
        return;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment