update field (#8)
Reviewed-on: #8 Co-authored-by: andrey <andrey@4devs.io> Co-committed-by: andrey <andrey@4devs.io>
This commit was merged in pull request #8.
This commit is contained in:
@@ -2,7 +2,22 @@ package field
|
||||
|
||||
type Fields []Field
|
||||
|
||||
type MapField map[Key]Value
|
||||
func (f Fields) Fields(fn func(Field) bool) {
|
||||
for idx := range f {
|
||||
if !fn(f[idx]) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f Fields) Any() any {
|
||||
fields := make(map[string]any)
|
||||
for idx := range f {
|
||||
fields[f[idx].Key] = f[idx].Value.Any()
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
func (f Fields) Append(fields ...Field) Fields {
|
||||
f = append(f, fields...)
|
||||
@@ -17,13 +32,3 @@ func (f Fields) Set(idx int, field Field) {
|
||||
func (f Fields) Len() int {
|
||||
return len(f)
|
||||
}
|
||||
|
||||
func (f Fields) AsMap() MapField {
|
||||
fields := make(MapField, len(f))
|
||||
|
||||
for _, field := range f {
|
||||
fields[field.Key()] = field.Value()
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user