feat: inprogress
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user