https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Cloud.html#.run
context
gets passed to all cloud triggers, and can be very helpful to provide additional information to your trigger. You can pass context in .save
, .find
calls, etc, and can access via req.context
.
Here is the example in the JS docs:
const TeamMember = Parse.Object.extend("TeamMember"); const teamMember = new TeamMember(); teamMember.set("team", "A"); const context = { notifyTeam: false }; await teamMember.save(null, { context: context });
The context is then accessible in Cloud Code:
Parse.Cloud.afterSave("TeamMember", async (req) => { const notifyTeam = req.context.notifyTeam; if (notifyTeam) { // Notify team about new member. } });
I see that you opened a SO issue a few years ago relating to context. I’ve opened an issue in the docs repo to improve this. If you have any other recommendations for improvements to our docs (or would like to be involved in the doc improvement process), please let us know