Documentation ¶
Index ¶
- type BucketRef
- type DatabaseRef
- func (dbRef *DatabaseRef) AddDefaultBucket(name []byte) BucketRef
- func (dbRef *DatabaseRef) Dump() (object *frjson.Object, result logging.Result)
- func (dbRef *DatabaseRef) Initialise(object *frjson.Object) logging.Result
- func (dbRef *DatabaseRef) Initialised() bool
- func (dbRef *DatabaseRef) Remove() logging.Result
- func (dbRef *DatabaseRef) SetPath(path string) logging.Result
- func (dbRef *DatabaseRef) Update(object *frjson.Object) logging.Result
- type KeyRef
- type MissingDBKeyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketRef ¶
type BucketRef struct { *DatabaseRef Name []byte }
BucketRef represents a reference by name to a bucketRef in the Bolt DB. Bolt defaultBuckets group together key/value pairs and can also contain other buckets to allow a hierarchical data structure
func (BucketRef) ForEach ¶
ForEach cycles through each key-value pair in the bucket Note that this is read only
func (BucketRef) GetAs ¶
GetAs unmarshals the data stored in the BucketRef into the supplied interface
func (BucketRef) RemoveAll ¶
RemoveAll removes all key-value pairs from a bucket
type DatabaseRef ¶
DatabaseRef contains a database id
func NewDatabaseRef ¶
func NewDatabaseRef(locationFileName, defaultName string) DatabaseRef
NewDatabaseRef checks if a file containing the db location is present in the executable directory. If the file is present and the path it contains is valid then a new DatabaseRef is created based on that path. If the file is not present or the path is not valid then then the executable directory and default name will be used.
func (*DatabaseRef) AddDefaultBucket ¶
func (dbRef *DatabaseRef) AddDefaultBucket(name []byte) BucketRef
AddDefaultBucket adds to the list of buckets automatically created at the root of the database at initialisation
func (*DatabaseRef) Dump ¶
func (dbRef *DatabaseRef) Dump() (object *frjson.Object, result logging.Result)
Dump will read all of the database's decrypted contents into a JSON object
func (*DatabaseRef) Initialise ¶
func (dbRef *DatabaseRef) Initialise(object *frjson.Object) logging.Result
Initialise initialises the database and stores the object (if not nil) in the root of the database
func (*DatabaseRef) Initialised ¶
func (dbRef *DatabaseRef) Initialised() bool
Initialised returns true if the database has been initialised; otherwise false is returned
func (*DatabaseRef) Remove ¶
func (dbRef *DatabaseRef) Remove() logging.Result
Remove completely removes the database
func (*DatabaseRef) SetPath ¶
func (dbRef *DatabaseRef) SetPath(path string) logging.Result
SetPath sets the path and\or name used by the database
func (*DatabaseRef) Update ¶
func (dbRef *DatabaseRef) Update(object *frjson.Object) logging.Result
Update stores the object in the root of the database Each JSON object will be represented by a db bucketRef with the object's value pairs as entries in the bucketRef. The defaultBuckets and entries will be created if they do not exist already. The JSON structure will be added to the root bucketRef, which can only contain other defaultBuckets and therefore the JSON structure should only contain objects in its root. Any value pairs will be ignored.
type KeyRef ¶
KeyRef is a reference to a named key in a bucket
func (KeyRef) GetAs ¶
GetAs will read the entry at the given key. The entry will be read into value, which must be a pointer to the same type as the entry
func (KeyRef) Put ¶
Put will update/insert the entry at the given key
type MissingDBKeyError ¶
type MissingDBKeyError struct {
// contains filtered or unexported fields
}
MissingDBKeyError is an error used to report a missing key in a database
func (MissingDBKeyError) Error ¶
func (e MissingDBKeyError) Error() string
Error satisfies the error interface