As I noticed, the request.object in the beforeSave is already modified. I am investigating the following concept of last update wins:
-
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", ... } -
user A send modified fields with ParseSwift
.save()and incontextwould be a date set (basically when that update was triggered, and can be also an old date in case or poor connectivity -
in the
beforeSavetrigger the function would go through thedirtyKeysand compare if the date incontextis larger than the one in relatedupdates.otherField -
if the
contextdate 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 -
if
contextdate is larger, theupdates.otherFielddate gets set to the same value as in thecontext
what would be a reasonable way to do?
-
set that field value from the
originalobject in that beforeSave trigger? -
use
revert(…keys)function in that beforeSave trigger? -
is there any smarter way how to implement some kind of simple last update wins?
Thank you!