Change from 'Value' to 'String'

This commit is contained in:
Brian Buller 2023-05-25 09:40:03 -05:00
parent 2121e5a434
commit 8c9a920404
1 changed files with 16 additions and 16 deletions

View File

@ -104,7 +104,7 @@ func (b *DB) MkBucketPath(path []string) error {
func (b *DB) Set(path []string, key string, val interface{}) error {
switch v := val.(type) {
case string:
return b.SetValue(path, key, v)
return b.SetString(path, key, v)
case int:
return b.SetInt(path, key, v)
case bool:
@ -180,10 +180,10 @@ func (b *DB) SetBytes(path []string, key string, val []byte) error {
return err
}
// GetValue returns the value at path
// GetString returns the value at path
// path is a slice of strings
// key is the key to get
func (b *DB) GetValue(path []string, key string) (string, error) {
func (b *DB) GetString(path []string, key string) (string, error) {
var err error
var ret string
if !b.dbIsOpen {
@ -210,9 +210,9 @@ func (b *DB) GetValue(path []string, key string) (string, error) {
return ret, err
}
// SetValue sets the value of key at path to val
// SetString sets the value of key at path to val
// path is a slice of tokens
func (b *DB) SetValue(path []string, key, val string) error {
func (b *DB) SetString(path []string, key, val string) error {
var err error
if !b.dbIsOpen {
if err = b.OpenDB(); err != nil {
@ -246,7 +246,7 @@ func (b *DB) SetValue(path []string, key, val string) error {
// If the value cannot be parsed as an int, error
func (b *DB) GetInt(path []string, key string) (int, error) {
var ret int
r, err := b.GetValue(path, key)
r, err := b.GetString(path, key)
if err == nil {
ret, err = strconv.Atoi(r)
}
@ -255,7 +255,7 @@ func (b *DB) GetInt(path []string, key string) (int, error) {
// SetInt Sets an integer value
func (b *DB) SetInt(path []string, key string, val int) error {
return b.SetValue(path, key, strconv.Itoa(val))
return b.SetString(path, key, strconv.Itoa(val))
}
// GetBool returns the value at 'path'
@ -263,7 +263,7 @@ func (b *DB) SetInt(path []string, key string, val int) error {
// We check 'true/false' and '1/0', else error
func (b *DB) GetBool(path []string, key string) (bool, error) {
var ret bool
r, err := b.GetValue(path, key)
r, err := b.GetString(path, key)
if err == nil {
if r == "true" || r == "1" {
ret = true
@ -277,15 +277,15 @@ func (b *DB) GetBool(path []string, key string) (bool, error) {
// SetBool Sets a boolean value
func (b *DB) SetBool(path []string, key string, val bool) error {
if val {
return b.SetValue(path, key, "true")
return b.SetString(path, key, "true")
}
return b.SetValue(path, key, "false")
return b.SetString(path, key, "false")
}
// GetTimestamp returns the value at 'path'
// If the value cannot be parsed as a RFC3339, error
func (b *DB) GetTimestamp(path []string, key string) (time.Time, error) {
r, err := b.GetValue(path, key)
r, err := b.GetString(path, key)
if err == nil {
return time.Parse(time.RFC3339, r)
}
@ -294,7 +294,7 @@ func (b *DB) GetTimestamp(path []string, key string) (time.Time, error) {
// SetTimestamp saves a timestamp into the db
func (b *DB) SetTimestamp(path []string, key string, val time.Time) error {
return b.SetValue(path, key, val.Format(time.RFC3339))
return b.SetString(path, key, val.Format(time.RFC3339))
}
// GetBucketList returns a list of all sub-buckets at path
@ -441,8 +441,8 @@ func (b *DB) DeleteBucket(path []string, key string) error {
return err
}
// GetValueList returns a string slice of all values in the bucket at path
func (b *DB) GetValueList(path []string) ([]string, error) {
// GetStringList returns a string slice of all values in the bucket at path
func (b *DB) GetStringList(path []string) ([]string, error) {
var err error
var ret []string
if !b.dbIsOpen {
@ -480,8 +480,8 @@ func (b *DB) GetValueList(path []string) ([]string, error) {
return ret, err
}
// SetValueList puts a string slice into the bucket at path
func (b *DB) SetValueList(path, values []string) error {
// SetStringList puts a string slice into the bucket at path
func (b *DB) SetStringList(path, values []string) error {
var err error
if !b.dbIsOpen {
if err = b.OpenDB(); err != nil {