-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary.go
34 lines (30 loc) · 885 Bytes
/
dictionary.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package storage
import (
"context"
"fmt"
"github.com/ErikKalkoken/evebuddy/internal/storage/queries"
)
func (r *Storage) GetDictEntry(ctx context.Context, key string) ([]byte, error) {
obj, err := r.q.GetDictEntry(ctx, key)
if err != nil {
return nil, fmt.Errorf("failed to get dict entry for key %s: %w", key, err)
}
return obj.Value, nil
}
func (r *Storage) DeleteDictEntry(ctx context.Context, key string) error {
err := r.q.DeleteDictEntry(ctx, key)
if err != nil {
return fmt.Errorf("failed to delete setting for key %s: %w", key, err)
}
return nil
}
func (r *Storage) SetDictEntry(ctx context.Context, key string, bb []byte) error {
arg := queries.UpdateOrCreateDictEntryParams{
Value: bb,
Key: key,
}
if err := r.q.UpdateOrCreateDictEntry(ctx, arg); err != nil {
return fmt.Errorf("failed to set setting for key %s: %w", key, err)
}
return nil
}