Documentation
¶
Index ¶
- Constants
- Variables
- type Gob
- type KV
- type Log
- type Marshalers
- type Node
- func (n Node) All(slicePtr interface{}, prefix string) error
- func (n Node) Delete(k string) error
- func (n Node) Drop() error
- func (n Node) Each(v interface{}, prefix string, fn func(k string) error) error
- func (n Node) EachKey(prefix string, fn func(k string) error) error
- func (n Node) Get(k string, v interface{}) error
- func (n Node) Node(name string) Node
- func (n Node) Prefix() string
- func (n Node) Set(k string, v interface{}) error
- func (n Node) SetWithTTL(k string, v interface{}, ttl time.Duration) error
Constants ¶
View Source
const Delimiter = ":::"
Variables ¶
View Source
var EachBreak = errors.New("each break (not an error)")
EachBreak is an error that Each callbacks could return to stop the loop and return nil.
View Source
var ErrKeyNotFound = errors.New("Key not found in database")
Functions ¶
This section is empty.
Types ¶
type KV ¶
type KV struct { Marshalers DB *badger.DB // contains filtered or unexported fields }
type Marshalers ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (Node) All ¶
All scans all values with the key prefix into the slice. This method uses reflection.
func (Node) Each ¶
Each iterates over the bucket all possible keys with the prefix, or no prefix. It takes in a pointer.
Caveats ¶
Since the pointer is reused, the user will need to manually copy it if they want to store the reference to that matched struct. Key includes the prefix.
Example ¶
For iterating, as mentioned above, the user will need to manually copy the pointer by dereferencing and re-referencing it.
var obj = &Struct{} var objs = []*Struct{} n.Each(obj, "", func(k string) error { if obj.Thing == "what I want" { cpy := *obj // copy objs = append(objs, &cpy) } return nil })
Click to show internal directories.
Click to hide internal directories.