Prior to updating to parse-server 3.0 I was putting the after/before save triggers in a model class and had no issue with them running but afte updating to 3.0 they are not called. Can these cloud code triggers exist outside of the cloud code file?
What do you mean outside of the cloud code file ?
You can put anywhere when you working with parse
@rgunindi Sorry I just saw your response from some months ago.
Aside from the cloud functions I have defined in cloud/main.js, I am also defining cloud code functions outside of that file. For example I have one file as follows located in the models folder:
models/Incident.js
Parse.Cloud.afterSave("Incident", (request) => {
// do something after saving the object
}
This was working fine before updating to parse-server 3.0 but now that I have upgraded I see the following error when starting up my parse server:
TypeError: Parse.Cloud.afterSave is not a function
If I move the afterSave trigger to cloud/main.js then the error goes away and the afterSave trigger works. I want to avoid doing this since I have a lot of classes that share the same style of code and that would require me to move multiple afterSave triggers to main.js.
For example, Iām using like this:
cloud/main.js
const {Parse} = require("parse");
require('./triggers/test')
cloud/triggers/test.js
Parse.Cloud.beforeDelete("test", async (req) => {
console.log("beforeDelete",req.object);
});