Skip to content

Be able to run the afterFind trigger automatically after saving object #7064

Closed
@AurelienVasseur

Description

@AurelienVasseur

Is your feature request related to a problem? Please describe.

I would like to be able to execute an afterFind trigger after saving an object on database.

For example, if we change the object before saving it, we will receive these changes on the app automatically.
But maybe in the app we don't want them.

This situation appears when an object don't have the same interface between the app and the database.

  • on beforeSave we adapt / change the object for the database
  • on afterFind we adapt / change the object for the application

So currently, to fix my problem I need to do something like that:

await object.save();
await object.fetch();

So I think it's not good in term of optimization.
And with that I always run the beforeFind trigger while I don't want.

I'm not a Parse expert so there is maybe currently a way to do that (or to do something on the same spirit).
If this is the case please say it to me.

Describe the solution you'd like

  • A solution can be to specify that during the save call as an option
object.save( { runAfterFind: true } );
  • It can also be useful to be able to specify that in the beforeSave trigger as a third parameter
Parse.Cloud.beforeSave("myClass", async () => {
   // some code ....
}, {
   runAfterFind: true
});

An other way to see the problem can be: How can I execute a code which will change the returned value on a beforeSave trigger?

Thanks you in advance 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:questionSupport or code-level question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions