summaryrefslogtreecommitdiff
path: root/internal/model
diff options
context:
space:
mode:
Diffstat (limited to 'internal/model')
-rw-r--r--internal/model/commandtype_string.go25
-rw-r--r--internal/model/mutations.go36
2 files changed, 61 insertions, 0 deletions
diff --git a/internal/model/commandtype_string.go b/internal/model/commandtype_string.go
new file mode 100644
index 0000000..1ad4635
--- /dev/null
+++ b/internal/model/commandtype_string.go
@@ -0,0 +1,25 @@
+// Code generated by "stringer -type=CommandType"; DO NOT EDIT.
+
+package model
+
+import "strconv"
+
+func _() {
+ // An "invalid array index" compiler error signifies that the constant values have changed.
+ // Re-run the stringer command to generate them again.
+ var x [1]struct{}
+ _ = x[Create-0]
+ _ = x[Merge-1]
+ _ = x[Remove-2]
+}
+
+const _CommandType_name = "CreateMergeRemove"
+
+var _CommandType_index = [...]uint8{0, 6, 11, 17}
+
+func (i CommandType) String() string {
+ if i < 0 || i >= CommandType(len(_CommandType_index)-1) {
+ return "CommandType(" + strconv.FormatInt(int64(i), 10) + ")"
+ }
+ return _CommandType_name[_CommandType_index[i]:_CommandType_index[i+1]]
+}
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
+)