Refine types a bit more
This commit is contained in:
31
Spec.md
31
Spec.md
@@ -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:
|
Events in the log are to take form of:
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Seq int
|
// Server generated sequence number of the event - ie when it was applied
|
||||||
Type "create"|"update"|"delete"
|
Seq int `json:"seq"`
|
||||||
Hash string
|
// Type of the event - create, update, delete, defined by the client
|
||||||
ItemID string // uuid-v4
|
Type string `json:"type"`
|
||||||
EventID string // uuid-v4
|
// Hash of the event - server generated, gurantees the event was processed
|
||||||
Data map[string]interface{}
|
Hash string `json:"hash"`
|
||||||
Timestamp datetime
|
// 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
|
Events are divided into 3 types, create update and delete events
|
||||||
Create events simply create the object as given in Data
|
Create events simply create the object as given in Data
|
||||||
@@ -34,3 +43,11 @@ And only then apply the patch
|
|||||||
For create events that is insert objects
|
For create events that is insert objects
|
||||||
For delete events that is mark objects as deleted
|
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...
|
||||||
|
23
types.go
23
types.go
@@ -3,13 +3,22 @@ package main
|
|||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type Event struct {
|
type Event struct {
|
||||||
Seq int `json:"seq"`
|
// Server generated sequence number of the event - ie when it was applied
|
||||||
Type string `json:"type"`
|
Seq int `json:"seq"`
|
||||||
Hash string `json:"hash"`
|
// Type of the event - create, update, delete, defined by the client
|
||||||
ItemID string `json:"item_id"`
|
Type string `json:"type"`
|
||||||
EventID string `json:"event_id"`
|
// Hash of the event - server generated, gurantees the event was processed
|
||||||
Data map[string]interface{} `json:"data"`
|
Hash string `json:"hash"`
|
||||||
Timestamp time.Time `json:"timestamp"`
|
// 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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SLItem struct {
|
type SLItem struct {
|
||||||
|
Reference in New Issue
Block a user