Documentation ¶
Overview ¶
simpledb package wraps a *bbolt.DB and provides methods for common operations
Index ¶
- Variables
- type BBolt
- type BoltLike
- type Bucket
- type Cursor
- type DB
- type Options
- type SimpleDB
- func (s *SimpleDB) Close() error
- func (s *SimpleDB) CreateBucket(bucketnames ...string) error
- func (s *SimpleDB) CreateBucketNested(bucketname string, nestednames ...string) error
- func (s *SimpleDB) CreatePaths(paths [][]string) error
- func (s *SimpleDB) DB() *bbolt.DB
- func (s *SimpleDB) Delete(fromBucket string, key ...string) error
- func (s *SimpleDB) DeleteNested(fromBucket, fromNested string, key ...string) error
- func (s *SimpleDB) ForEach(bucket string, fn func(k, v []byte) error) error
- func (s *SimpleDB) ForEachBucket(fn func(b []byte, bucket *Bucket) error) error
- func (s *SimpleDB) ForEachNested(bucket, nested string, fn func(k, v []byte) error) error
- func (s *SimpleDB) Get(bucket, key string) []byte
- func (s *SimpleDB) GetNested(bucket, nestedname, key string) []byte
- func (s *SimpleDB) GetPath(path []string) []byte
- func (s *SimpleDB) Keys(bucket string) []string
- func (s *SimpleDB) KeysNested(bucket, nestedname string) []string
- func (s *SimpleDB) Marshal(bucket, key string, thing interface{}) error
- func (s *SimpleDB) MarshalNested(bucket, nestedname, key string, thing interface{}) error
- func (s *SimpleDB) MarshalPath(path []string, thing interface{}) error
- func (s *SimpleDB) Put(bucket, key string, data []byte) error
- func (s *SimpleDB) PutNested(bucket, nestedname, key string, data []byte) error
- func (s *SimpleDB) PutPath(path []string, data []byte) error
- func (s *SimpleDB) Unmarshal(bucket, key string, thingPtr interface{}) error
- func (s *SimpleDB) UnmarshalNested(bucket, nestedname, key string, thingPtr interface{}) error
- func (s *SimpleDB) UnmarshalPath(path []string, thingPtr interface{}) error
- func (s *SimpleDB) Update(txfn func(tx *Tx) error) error
- func (s *SimpleDB) View(txfn func(tx *Tx) error) error
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ErrBucketNotFound = errors.New("bucket not found")
if a bucket or nested bucket can not be found during Read/View operations
var ErrDBType = errors.New("db not found, or type assertion failed, are you not using a *bbolt.DB ?")
ErrDBType will be given if a programmer is not using the library correctly ;)
var ErrEmptyPath = errors.New("empty path")
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound will be returned by Unmarshal functions if the key did not exist or gave empty value. For example, if the requested user does not exist in the database.
var ErrTimeout = bbolt.ErrTimeout
ErrTimeout returned if we can't get the lock on the db
var New = Load
New is an alias for Load()
Functions ¶
This section is empty.
Types ¶
type BoltLike ¶
type BoltLike interface {
Sync() error
}
BoltLike is any bolt-like DB package. This currently only supports bbolt
type SimpleDB ¶
type SimpleDB struct { //db *bbolt.DB D BoltLike }
SimpleDB ...
func Load ¶
Load a database, creating it, and making directories to it, if does not exist. Write operations (Update, Marshal, and their nested counterparts) create buckets if they don't exist. Read operations (Get, Unmarshal) will return nil if the bucket doesn't exist yet.
func WrapBoltDB ¶
WrapBoltDB ... do not use with non-bbolt db yet
func (*SimpleDB) CreateBucket ¶
CreateBucket makes sure your database is initialized. Do at beginning for each bucket your program will use. Or if creating many buckets dynamically, just make sure CreateBucket is called before any Read operations happen. Example: s.CreateBucket("contacts"); s.Unmarshal("contacts", "bob", &user);
func (*SimpleDB) CreateBucketNested ¶
CreateBucketNested makes sure your database is initialized. Do at beginning for each bucket your program will use. Or if creating many buckets dynamically, just make sure CreateBucket is called before any Read operations happen.
func (*SimpleDB) CreatePaths ¶
func (*SimpleDB) DeleteNested ¶
DeleteNested keys from nested bucket
func (*SimpleDB) ForEachBucket ¶
ForEach bucket...
func (*SimpleDB) ForEachNested ¶
ForEachNested key in a named nested bucket...
func (*SimpleDB) KeysNested ¶
KeysNested lists key names within nested bucket
func (*SimpleDB) MarshalNested ¶
MarshalNested writes to database
func (*SimpleDB) MarshalPath ¶
func (*SimpleDB) UnmarshalNested ¶
Unmarshal a nested value