chore: make connection paging more like standard

This commit is contained in:
Jon Lundy
2022-10-25 20:15:57 -06:00
parent 7ae2a8ad25
commit 9dd9443bc9
14 changed files with 350 additions and 41 deletions

View File

@@ -60,6 +60,9 @@ func (lis Events) StreamID() string {
func (lis Events) SetStreamID(streamID string) {
SetStreamID(streamID, lis...)
}
func (lis Events) Count() int64 {
return int64(len(lis))
}
func (lis Events) First() Event {
if len(lis) == 0 {
return NilEvent

View File

@@ -261,11 +261,30 @@ func Values(e Event) map[string]any {
continue
}
omitempty := false
field := v.FieldByIndex(idx.Index)
name := idx.Name
if n, ok := idx.Tag.Lookup("json"); ok {
name = n
var (
opt string
found bool
)
name, opt, found = strings.Cut(n, ",")
if name == "-" {
continue
}
if found {
if strings.Contains(opt, "omitempty") {
omitempty = true
}
}
}
if omitempty && field.IsZero() {
continue
}
m[name] = field.Interface()