[feat] OperationAccess 优化

This commit is contained in:
what 2024-05-06 15:41:33 +08:00
parent a2fed1cb5b
commit b6347d7963

View File

@ -29,13 +29,13 @@ func (this *OperationAccess) Set(k string, v []any) error {
return this.Push(k, v...) return this.Push(k, v...)
} }
func (this *OperationAccess) Push(k string, input ...any) error { func (this *OperationAccess) Push(k string, ids ...any) error {
if _, ok := this.data[k]; !ok { if _, ok := this.data[k]; !ok {
this.Set(k, []any{}) this.Set(k, []any{})
} }
for i := 0; i < len(input); i++ { for i := 0; i < len(ids); i++ {
if v, err := this.Convert(input[i]); err != nil { if v, err := this.Convert(ids[i]); err != nil {
return err return err
} else if !lo.Contains(this.data[k], v) { } else if !lo.Contains(this.data[k], v) {
this.data[k] = append(this.data[k], v) this.data[k] = append(this.data[k], v)