Skip to content

Add index and count properties to beforeSave and afterSave hooks #5667

@stevestencil

Description

@stevestencil

Is your feature request related to a problem? Please describe.
When saving a bunch of objects at once (i.e. Parse.Object.saveAll()), It would be nice to be able to run a beforeSave or afterSave hook once for all objects.

Describe the solution you'd like
It would nice to have additional properties on the request argument like objectCount and index where objectCount would represent the number of objects that were saved and index would be the index of the current object that is calling the beforeSave hook. You could then use these two properties to check if the object is first index, last index, etc.

Describe alternatives you've considered
Another option would be to create a beforeSaveAll and afterSaveAll function that would be called once before all objects are saved and it would pass in the array of objects. We could then manipulate all objects at once in the beforeSave without having to make a callout for each object.

Additional context
I would be happy to try and tackle this feature if you point me in the right direction on where to start and any feedback on ways to make it better.

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