bbolt

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(db *bolt.DB, bucketName, key string) error

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

func Get(db *bolt.DB, bucketName, key string) string

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

func GetAll(db *bolt.DB, bucketName string) map[string]string

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

func GetAllWitPrefix(db *bolt.DB, bucketName, prefix string) map[string]string

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

func GetFromJson(db *bolt.DB, bucketName, key string) (map[string]interface{}, error)

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

func Initialize(dbPath, bucketName string) (*bolt.DB, error)

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

func Save(db *bolt.DB, bucketName, key, value string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL