Prevent setting certain fields in beforeSave

As I noticed, the request.object in the beforeSave is already modified. I am investigating the following concept of last update wins:

  1. object in database has a nested object with fields and related last update dates. for example
    "updated" { "age": "2021-05-7T12:00:00.000Z", "otherField": "2021-05-7T12:00:00.000Z", ... }

  2. user A send modified fields with ParseSwift .save() and in context would be a date set (basically when that update was triggered, and can be also an old date in case or poor connectivity

  3. in the beforeSave trigger the function would go through the dirtyKeys and compare if the date in context is larger than the one in related updates.otherField

  4. if the context date is lower, it means that the value was updated by a newer one. In this case I would need to throw away that particular field’s update

  5. if context date is larger, the updates.otherField date gets set to the same value as in the context

what would be a reasonable way to do?

  1. set that field value from the original object in that beforeSave trigger?

  2. use revert(…keys) function in that beforeSave trigger?

  3. is there any smarter way how to implement some kind of simple last update wins?

Thank you!

I would go for restoring data from request.original.