Skip to content

RFC: Save Triggers should be able to filter Operations #7220

@sadortun

Description

@sadortun

New Feature / Enhancement Checklist

Current Limitation

If this is approved by the maintainers we will submit a PR in the near future

Very simple use case and i think this feature could be used in many cases. Lets say you have a counter, and you want to limit operations on it.

Feature / Enhancement Description

Since triggers can already perform validation operations on fields, add a way to validate the type of operation that are performed

Example Use Case

Parse.Cloud.beforeSave('GameScore', (request) => {

  // ....
  
}, {
  fields: {
    score: {
      required : true,
      opType :  Parse.Op.Increment 
    },
    otherTeamScore: {
      required : true,
      opType : [ Parse.Op.Unset , Parse.Op.Increment ]
    },
  }
})

Alternatives / Workarounds

In the trigger, iterate through req.object._getPendingOps()

3rd Party References

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions