# Parse.Cloud.afterSave in model class

**URL:** <https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807>\
**Category:** Parse Server 📡\
**Created:** [February 5, 2025, 7:44am UTC](https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807 "2025-02-05T07:44:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adammlevy](https://community.parseplatform.org/user_avatar/community.parseplatform.org/adammlevy/32/800_2.png) [@adammlevy](https://community.parseplatform.org/u/adammlevy)\
**Post date:** [February 5, 2025, 7:44am UTC](https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807/1 "2025-02-05T07:44:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rgunindi](https://community.parseplatform.org/user_avatar/community.parseplatform.org/rgunindi/32/1553_2.png) [@rgunindi](https://community.parseplatform.org/u/rgunindi)\
**Post date:** [February 6, 2025, 1:45pm UTC](https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807/2 "2025-02-06T13:45:42Z")

</div>

What do you mean outside of the cloud code file ?

You can put anywhere when you working with parse

---

<div class="post-metadata">

**Author:** ![adammlevy](https://community.parseplatform.org/user_avatar/community.parseplatform.org/adammlevy/32/800_2.png) [@adammlevy](https://community.parseplatform.org/u/adammlevy)\
**Post date:** [May 27, 2025, 10:23pm UTC](https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807/3 "2025-05-27T22:23:44Z")

</div>

@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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![rgunindi](https://community.parseplatform.org/user_avatar/community.parseplatform.org/rgunindi/32/1553_2.png) [@rgunindi](https://community.parseplatform.org/u/rgunindi)\
**Post date:** [May 27, 2025, 10:43pm UTC](https://community.parseplatform.org/t/parse-cloud-aftersave-in-model-class/4807/4 "2025-05-27T22:43:22Z")

</div>

> [@adammlevy](#):
>
> 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:
> 
> ```auto
> 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

```auto
const {Parse} = require("parse");

require('./triggers/test')

```

cloud/triggers/test.js

```auto
Parse.Cloud.beforeDelete("test", async (req) => {
    console.log("beforeDelete",req.object);
});

```
