feat: inprogress

This commit is contained in:
Jon Lundy
2022-08-23 21:24:13 -06:00
parent 0a964cb631
commit 8c54eefcdd
20 changed files with 1316 additions and 28 deletions

View File

@@ -29,16 +29,16 @@ func Append(a Aggregate, lis ...Event) {
// NotExists returns error if there are no events present.
func NotExists(a Aggregate) error {
if a.StreamVersion() != 0 {
return fmt.Errorf("%w, got version == %d", ErrShouldNotExist, a.StreamVersion())
if a.Version() != 0 {
return fmt.Errorf("%w, got version == %d", ErrShouldNotExist, a.Version())
}
return nil
}
// ShouldExists returns error if there are no events present.
func ShouldExist(a Aggregate) error {
if a.StreamVersion() == 0 {
return fmt.Errorf("%w, got version == %d", ErrShouldExist, a.StreamVersion())
if a.Version() == 0 {
return fmt.Errorf("%w, got version == %d", ErrShouldExist, a.Version())
}
return nil
}

View File

@@ -246,3 +246,12 @@ func embedJSON(s string) json.RawMessage {
}
return []byte(fmt.Sprintf(`"%s"`, strings.Replace(s, `"`, `\"`, -1)))
}
func values(e Event) map[string]any {
m := make(map[string]any)
v := reflect.ValueOf(e)
for _, idx := range reflect.VisibleFields(v) {
field := v.FieldByIndex(idx.Index)
m[field.]
}
}