MCPcopy
hub / github.com/TomWright/dasel / Modify

Function Modify

api.go:53–64  ·  view source on GitHub ↗

Modify runs the query against the given data and updates it in-place. Given data must be a pointer to a mutable data structure.

(ctx context.Context, data any, selector string, newValue any, opts ...execution.ExecuteOptionFn)

Source from the content-addressed store, hash-verified

51// Modify runs the query against the given data and updates it in-place.
52// Given data must be a pointer to a mutable data structure.
53func Modify(ctx context.Context, data any, selector string, newValue any, opts ...execution.ExecuteOptionFn) (int, error) {
54 res, count, err := Query(ctx, data, selector, opts...)
55 if err != nil {
56 return 0, err
57 }
58 for _, v := range res {
59 if err := v.Set(model.NewValue(newValue)); err != nil {
60 return 0, err
61 }
62 }
63 return count, nil
64}

Callers

nothing calls this directly

Calls 3

NewValueFunction · 0.92
QueryFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected