Documentation ¶
Index ¶
- Constants
- Variables
- func MapToStruct(dst any, src map[string]any) error
- func StructToMap(dst map[string]any, src any) error
- type Jsondb
- func (db *Jsondb) Delete(keysStr string) error
- func (db *Jsondb) Divider() string
- func (db *Jsondb) GetAllMaps(keysStr string) ([]map[string]any, error)
- func (db *Jsondb) GetAny(keysStr string) (any, error)
- func (db *Jsondb) GetBool(keysStr string) (bool, error)
- func (db *Jsondb) GetFloat(keysStr string) (float64, error)
- func (db *Jsondb) GetInt(keysStr string) (int, error)
- func (db *Jsondb) GetLen(keysStr string) (int, error)
- func (db *Jsondb) GetMap(keysStr string) (map[string]any, error)
- func (db *Jsondb) GetString(keysStr string) (string, error)
- func (db *Jsondb) GetStruct(keysStr string, dst any) error
- func (db *Jsondb) Insert(keysStr string, value any) error
- func (db *Jsondb) InsertDir(dirsStr string) error
Constants ¶
const ( DatabaseFileType = ".json" DirDefault = 0755 FileDefault = 0644 )
Variables ¶
var (
ErrorTypeConverting = errors.New("can't convert type")
)
Functions ¶
func MapToStruct ¶
MapToStruct converts a map to a struct.
dst: Pointer to destination variable to store the converted struct value. src: The map containing the data to be converted to a struct. error: Returns an error if any.
Types ¶
type Jsondb ¶
type Jsondb struct {
// contains filtered or unexported fields
}
func New ¶
New initializes a new json database at the specified path with an optional divider string.
path: the file path where the jsondb will be created. divider: an optional string used to divide nested keys in the jsondb. Returns a pointer to the newly initialized Jsondb instance and an error.
func (*Jsondb) Delete ¶
Delete deletes all values stored under the specified key.
keysStr: A string representing the path to the desired values. error: An error if any occurs during the delete operation. Returns: An error if any occurs during the delete operation.
func (*Jsondb) GetAllMaps ¶
GetAllMaps retrieves all map values from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns an array of map values found at the given keys and an error if any.
func (*Jsondb) GetAny ¶
GetAny retrieves an any value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the any value found at the given keys and an error if not.
func (*Jsondb) GetBool ¶
GetBool retrieves a boolean value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the boolean value found at the given keys and an error if any.
func (*Jsondb) GetFloat ¶
GetFloat retrieves an float value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the float64 value found at the given keys and an error if any.
func (*Jsondb) GetInt ¶
GetInt retrieves an integer value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the integer value found at the given keys and an error if any.
func (*Jsondb) GetLen ¶
GetLen retrieves the number of entries in a directory specified by the given keys.
keysStr: A string representing the path to the directory. Returns the number of entries in the directory.
func (*Jsondb) GetMap ¶
GetMap retrieves a map value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the map value found at the given keys and an error if any.
func (*Jsondb) GetString ¶
GetString retrieves an integer value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. Returns the string value found at the given keys and an error if any.
func (*Jsondb) GetStruct ¶
GetStruct retrieves a struct value from the JSON database based on the specified keys.
keysStr: A string representing the path to the desired integer value. dst: Pointer to destination variable to store the retrieved struct value. Returns an error if any.