Refine types a bit more

This commit is contained in:
2025-09-26 09:27:08 +02:00
parent df397f5f1d
commit 1a7be88105
2 changed files with 41 additions and 15 deletions

33
Spec.md
View File

@@ -6,13 +6,22 @@ For performance reasons we are to cache these data rows as well for quick lookup
Events in the log are to take form of:
type Event struct {
Seq int
Type "create"|"update"|"delete"
Hash string
ItemID string // uuid-v4
EventID string // uuid-v4
Data map[string]interface{}
Timestamp datetime
// Server generated sequence number of the event - ie when it was applied
Seq int `json:"seq"`
// Type of the event - create, update, delete, defined by the client
Type string `json:"type"`
// Hash of the event - server generated, gurantees the event was processed
Hash string `json:"hash"`
// ItemID of the item that is to be manipulated, defined by the client
ItemID string `json:"item_id"`
// EventID of the event - server generated, gurantees the event was processed
EventID string `json:"event_id"`
// Collection of the item that is to be manipulated, defined by the client
Collection string `json:"collection"`
// Data that is to be used for manipulation; for create events that's the full objects and for update events that's the diff
Data map[string]interface{} `json:"data"`
// Timestamp of the event - server generated, when the event was processed
Timestamp time.Time `json:"timestamp"`
}
Events are divided into 3 types, create update and delete events
Create events simply create the object as given in Data
@@ -33,4 +42,12 @@ Compute the hash from the dump of the current event PLUS the previous event's ha
And only then apply the patch
For create events that is insert objects
For delete events that is mark objects as deleted
For update events get the object, apply the diff and sav the object
For update events get the object, apply the diff and sav the object
---
Actually for pocketbase we might want to generalize this
Maybe create a "Collection" field as well and allow the events to manipulate any table...
That way our Data isn't tied to a table...