summaryrefslogtreecommitdiff
path: root/internal/model/mutations.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/model/mutations.go')
-rw-r--r--internal/model/mutations.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/model/mutations.go b/internal/model/mutations.go
new file mode 100644
index 0000000..6463823
--- /dev/null
+++ b/internal/model/mutations.go
@@ -0,0 +1,36 @@
+package model
+
+import (
+ "fmt"
+ "strings"
+ "time"
+
+ "go.neonxp.dev/json/model"
+)
+
+type Mutation struct {
+ Date time.Time
+ Type CommandType
+ Path []string
+ Body model.Node
+}
+
+func (m *Mutation) String() string {
+ body, _ := m.Body.MarshalJSON()
+ return fmt.Sprintf(
+ "Date=%s Type=%s Path='%s' Body=%s",
+ m.Date.Format(time.RFC3339),
+ m.Type,
+ strings.Join(m.Path, "/"),
+ string(body),
+ )
+}
+
+//go:generate stringer -type=CommandType
+type CommandType int
+
+const (
+ Create CommandType = iota
+ Merge
+ Remove
+)