connect

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2017 License: MIT Imports: 4 Imported by: 1

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	DBName  string
	Address string
}

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) Get

func (c *Connection) Get(bucket string, keys []string) (map[string]string, error)

Get keys and values from 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.

func (*Connection) Pop

func (c *Connection) Pop(bucket string, n int) (keystore map[string]string, err error)

Pop returns and deletes the first n keys from a bucket

func (*Connection) Post

func (c *Connection) Post(bucket string, keystore map[string]string) error

Post keys and values to database

func (*Connection) Stats

func (c *Connection) Stats() (stats map[string]int, err error)

Stats returns a list of buckets and number of keys in each

Jump to

Keyboard shortcuts

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