Add 'Set' for interface{} type

This commit is contained in:
Brian Buller 2022-11-15 17:03:40 -06:00
parent a3bfc9ba7b
commit 4c7d152811

View File

@ -2,6 +2,7 @@ package boltease
import ( import (
"encoding/binary" "encoding/binary"
"errors"
"fmt" "fmt"
"os" "os"
"strconv" "strconv"
@ -100,6 +101,20 @@ func (b *DB) MkBucketPath(path []string) error {
return err 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) { func (b *DB) GetBytes(path []string, key string) ([]byte, error) {
var err error var err error
var ret []byte var ret []byte