MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / Set

Method Set

stores/setting/store.go:35–58  ·  view source on GitHub ↗
(ctx context.Context, name string, value string, operator string)

Source from the content-addressed store, hash-verified

33}
34
35func (i *imlSettingStore) Set(ctx context.Context, name string, value string, operator string) error {
36 return i.Store.Transaction(ctx, func(ctx context.Context) error {
37 v, err := i.Store.First(ctx, map[string]interface{}{"name": name})
38 if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
39 return err
40 }
41 if v == nil {
42 v = &Setting{
43 Name: name,
44 CreateAt: time.Now(),
45 UpdateAt: time.Now(),
46 Value: value,
47 Operator: operator,
48 }
49 return i.Store.Insert(ctx, v)
50 }
51 v.Value = value
52 v.Operator = operator
53 v.UpdateAt = time.Now()
54 _, err = i.Store.Update(ctx, v)
55 return err
56
57 })
58}
59
60func init() {
61 autowire.Auto[ISettingStore](func() reflect.Value {

Callers

nothing calls this directly

Calls 1

UpdateMethod · 0.65

Tested by

no test coverage detected