Record local edits#
Record each change your application makes as you make it, and the next sync sends it.
Create and change#
lunch = adapter.create(b"Lunch with Ana")
meeting = replica.find_record("work", "meeting")
if meeting is not None:
adapter.change(meeting.local_key, b"Team meeting, room 3")
adapter.sync()
create() returns the new record’s local key, which stays the same once the server gives the object an id. Edits go through the adapter, which reads their fingerprint the same way it reads the server’s copy.
Undo an edit#
adapter.change(lunch, b"Lunch with Ana and Ben")
replica.discard(lunch)
discard() drops an edit the server hasn’t received.
Delete#
replica.delete(lunch)
adapter.sync()
An event with an open conflict takes no edit until you resolve it, as Resolve conflicts shows.