database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BOLT_DB - BoltDB
	BOLT_DB = "boltdb"
	// BUNT_DB - BuntDB
	BUNT_DB = "buntdb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

type BoltDB struct {
	*bolt.DB
	// contains filtered or unexported fields
}

BoltDB - BoltDB struct

func (*BoltDB) Add

func (db *BoltDB) Add(key string, value string, args ...interface{}) error

Add godoc - Adds a new key/value pair to the database

func (*BoltDB) AddBucket added in v0.2.0

func (db *BoltDB) AddBucket(bucketName string) error

AddBucket godoc - Adds a new bucket to the database

func (*BoltDB) CloseDB

func (db *BoltDB) CloseDB()

CloseDB godoc - Closes the database

func (*BoltDB) Conn added in v0.2.0

func (db *BoltDB) Conn() interface{}

Conn godoc - Returns the underlying database connection

func (*BoltDB) Delete

func (db *BoltDB) Delete(key string) error

Delete godoc - Deletes a key/value pair from the database

func (*BoltDB) DeleteBucket added in v0.2.0

func (db *BoltDB) DeleteBucket(bucketName string) error

DeleteBucket godoc - Deletes a bucket from the database

func (*BoltDB) Get

func (db *BoltDB) Get(key string) (string, error)

Get godoc - Gets a value from the database

func (*BoltDB) GetDefBucket added in v0.2.0

func (db *BoltDB) GetDefBucket() string

SetBucket godoc - Sets the current bucket

func (*BoltDB) List

func (db *BoltDB) List(args ...interface{}) (data []KeyValuePair, err error)

List godoc - Lists all key/value pairs in the database

func (*BoltDB) ListBuckets added in v0.2.0

func (db *BoltDB) ListBuckets() (data []string, err error)

ListBuckets godoc - Lists all buckets in the database

func (*BoltDB) SetBucket added in v0.2.0

func (db *BoltDB) SetBucket(bucketName string)

SetBucket godoc - Sets the current bucket

type BuntDB

type BuntDB struct {
	*buntdb.DB
}

BuntDB - BuntDB struct

func (*BuntDB) Add

func (db *BuntDB) Add(key string, value string, args ...interface{}) error

Add godoc - Adds a new key/value pair to the database

func (*BuntDB) CloseDB

func (db *BuntDB) CloseDB()

CloseDB godoc - Closes the database

func (*BuntDB) Conn added in v0.2.0

func (db *BuntDB) Conn() interface{}

Conn godoc - Returns the underlying database connection

func (*BuntDB) Delete

func (db *BuntDB) Delete(key string) error

Delete godoc - Deletes a key/value pair from the database

func (*BuntDB) Get

func (db *BuntDB) Get(key string) (string, error)

Get godoc - Gets a value from the database

func (*BuntDB) List

func (db *BuntDB) List(args ...interface{}) (data []KeyValuePair, err error)

List godoc - Lists all keys in the database

type DB

type DB interface {
	Conn() interface{}
	Add(string, string, ...interface{}) error
	CloseDB()
	Get(key string) (string, error) // TODO: add list all keys
	Delete(string) error
	List(args ...interface{}) ([]KeyValuePair, error)
}

DB interface for underlying database packages

func NewDB

func NewDB(fileName string, dbtype string) (DB, error)

NewDB godoc - creates a new DB instance abstracting the underlying database package

type DBType

type DBType string

DBType for identifying underlying database packages

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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