Add 'Set' for interface{} type

This commit is contained in:
Brian Buller 2022-11-15 17:03:40 -06:00
parent a3bfc9ba7b
commit 4c7d152811
1 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package boltease
import (
"encoding/binary"
"errors"
"fmt"
"os"
"strconv"
@ -100,6 +101,20 @@ func (b *DB) MkBucketPath(path []string) error {
return err
}
func (b *DB) Set(path []string, key string, val interface{}) error {
switch v := val.(type) {
case string:
return b.SetValue(path, key, v)
case int:
return b.SetInt(path, key, v)
case bool:
return b.SetBool(path, key, v)
case []byte:
return b.SetBytes(path, key, v)
}
return errors.New("Unknown Data Type")
}
func (b *DB) GetBytes(path []string, key string) ([]byte, error) {
var err error
var ret []byte