I am building an access control app for events. The tickets on those clients get synced ahead but I would like to store the current state in firestore, but they have to be updated in the correct order even if a device goes offline. My question is based on this stackoverflow answer which describe how the default "last write win" behavior works as well as this explanation. In the video he mentions that this can be changed by using security rules or cloud functions.
My approach with security rules:
service cloud.firestore {
match /databases/{database}/documents {
match /tickets/{ticket} {
allow update: if request.resource.data.localTimestamp > resource.data.timestamp;
}
}
}
Does someone have a working example? Or an approach with cloud functions?