Documentation ¶
Index ¶
- func Delete(db *bolt.DB, bucketName, key string) error
- func Get(db *bolt.DB, bucketName, key string) string
- func GetAll(db *bolt.DB, bucketName string) map[string]string
- func GetAllWitPrefix(db *bolt.DB, bucketName, prefix string) map[string]string
- func GetFromJson(db *bolt.DB, bucketName, key string) (map[string]interface{}, error)
- func Initialize(dbPath, bucketName string) (*bolt.DB, error)
- func Save(db *bolt.DB, bucketName, key, value string) error
- func SaveAsJson(db *bolt.DB, bucketName, key string, value map[string]interface{}) (map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete deletes a key-value pair from the specified bucket in the BoltDB database.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket from which the key-value pair is deleted. - key: The key of the key-value pair to be deleted.
Returns: - error: An error if the deletion operation fails.
func Get ¶
Get retrieves the value associated with the given key from the specified bucket in the BoltDB database.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket where the key-value pair is stored. - key: The key for which the value is retrieved.
Returns: - string: The value associated with the key, or an empty string if the key is not found.
func GetAll ¶
GetAll retrieves all key-value pairs from the specified bucket in the BoltDB database.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket from which the key-value pairs are retrieved.
Returns: - map[string]string: A map containing the key-value pairs from the specified bucket.
func GetAllWitPrefix ¶
GetAllWitPrefix retrieves all key-value pairs from the specified bucket in the BoltDB database that have a given prefix.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket from which the key-value pairs are retrieved. - prefix: The prefix used to filter the key-value pairs.
Returns: - map[string]string: A map containing the key-value pairs from the specified bucket that have the given prefix.
func GetFromJson ¶ added in v0.0.3
GetFromJson retrieves a map[string]interface{} value from a BoltDB database using the specified bucket name and key.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket where the key-value pair is stored. - key: The key for which the value is retrieved.
Returns: - map[string]interface{}: The retrieved value as a map, or nil if an error occurs. - error: An error if the JSON unmarshaling operation fails.
func Initialize ¶
Initialize initializes a new BoltDB database with the given database path and bucket name.
Parameters: - dbPath: The path to the BoltDB database file. - bucketName: The name of the bucket to be created in the database.
Returns: - *bolt.DB: The initialized BoltDB database connection. - error: An error if the initialization fails.
func Save ¶
Save saves the provided value in the specified bucket using the given key.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket where the data will be stored. - key: The key under which the data will be stored. - value: The value to be saved. Return type: error.
func SaveAsJson ¶ added in v0.0.3
func SaveAsJson(db *bolt.DB, bucketName, key string, value map[string]interface{}) (map[string]interface{}, error)
SaveAsJson saves a map[string]interface{} value as JSON in a BoltDB database.
Parameters: - db: The BoltDB database connection. - bucketName: The name of the bucket where the JSON data will be stored. - key: The key under which the JSON data will be stored. - value: The map[string]interface{} value to be saved as JSON.
Returns: - map[string]interface{}: The saved value. - error: An error if the JSON marshaling or saving operation fails.
Types ¶
This section is empty.