Documentation ¶
Overview ¶
Package connect provides functionality for directly accessing a BoltDB server instance with simple functions for posting data, getting data (such as keys and buckets), moving data, deleting data, and popping data.
To use, make sure that you have a boltdb-server up and running which you can do simply with
go get github.com/schollz/boltdb-server $GOPATH/bin/boltdb-server
Index ¶
- type Connection
- func (c *Connection) CreateBuckets(buckets []string) error
- func (c *Connection) DeleteDatabase() error
- func (c *Connection) Get(bucket string, keys []string) (map[string]string, error)
- func (c *Connection) GetAll(bucket string) (map[string]string, error)
- func (c *Connection) GetKeys(bucket string) ([]string, error)
- func (c *Connection) HasKey(bucket string, key string) (doesHaveKey bool, err error)
- func (c *Connection) HasKeys(buckets []string, keys []string) (doesHaveKeyMap map[string]bool, err error)
- func (c *Connection) Move(bucket string, bucket2 string, keys []string) (err error)
- func (c *Connection) Pop(bucket string, n int) (keystore map[string]string, err error)
- func (c *Connection) Post(bucket string, keystore map[string]string) error
- func (c *Connection) Stats() (stats map[string]int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection is the BoltDB server instance
func Open ¶
func Open(address, dbname string) (*Connection, error)
Open will load a connection to BoltDB
func (*Connection) CreateBuckets ¶
func (c *Connection) CreateBuckets(buckets []string) error
CreateBuckets inserts some buckets into the DB
func (*Connection) DeleteDatabase ¶
func (c *Connection) DeleteDatabase() error
DeleteDatabase deletes the database
func (*Connection) GetAll ¶
func (c *Connection) GetAll(bucket string) (map[string]string, error)
GetAll keys and values from database
func (*Connection) GetKeys ¶
func (c *Connection) GetKeys(bucket string) ([]string, error)
GetKeys returns all keys from database
func (*Connection) HasKey ¶
func (c *Connection) HasKey(bucket string, key string) (doesHaveKey bool, err error)
HasKey checks whether a key exists, or not, in a bucket
func (*Connection) HasKeys ¶
func (c *Connection) HasKeys(buckets []string, keys []string) (doesHaveKeyMap map[string]bool, err error)
HasKeys checks whether any of the specified keys exist in any buckets. Returns a map of the keys and a boolean of whether they are found.
func (*Connection) Move ¶
func (c *Connection) Move(bucket string, bucket2 string, keys []string) (err error)
Move moves a list of keys from one bucket to another. This function will create the second bucket if it does not exist.