Documentation ¶
Index ¶
- Variables
- func SetOffset(offset int)
- type BoltAPI
- func (db *BoltAPI) AddBucket(bucketName string) (err error)
- func (db *BoltAPI) AddRecord(key, value string) (err error)
- func (db *BoltAPI) Back() (data Data, err error)
- func (db *BoltAPI) Close() error
- func (db *BoltAPI) DeleteBucket(key string) (err error)
- func (db *BoltAPI) DeleteRecord(key string) (err error)
- func (db *BoltAPI) EditBucketName(oldKey, newKey string) (err error)
- func (db *BoltAPI) EditRecord(oldKey, newKey, newValue string) error
- func (db *BoltAPI) GetCurrent() (data Data, err error)
- func (db *BoltAPI) GetRoot() (data Data, err error)
- func (db *BoltAPI) Next(name string) (data Data, err error)
- func (db *BoltAPI) NextRecords() (data Data, err error)
- func (db *BoltAPI) PrevRecords() (data Data, err error)
- func (db *BoltAPI) Search(needle string) (records []Record, path string, recordsAmount int, err error)
- func (db *BoltAPI) SearchRegexp(expr string) (records []Record, path string, recordsAmount int, err error)
- type Data
- type Options
- type Record
Constants ¶
This section is empty.
Variables ¶
var (
ErrNeedWriteMode = errors.New("Need WriteMode. Mode of the db is ReadOnly")
)
Functions ¶
Types ¶
type BoltAPI ¶
type BoltAPI struct { Name string `json:"name"` DBPath string `json:"dbPath"` Size int64 `json:"size"` ReadOnly bool // contains filtered or unexported fields }
BoltAPI is a warrep for *bolt.DB
pages is a number of pages (1 page = maxOffset) 1 – [0, maxOffset) 2 – [maxOffset, 2*maxOffset) 3 – [2*maxOffset, 3*maxOffset) etc.
func Create ¶
Create a new db. If path consists only a name, the db will be created on the Desktop The function calls Open() and returns result of this calling
func (*BoltAPI) AddBucket ¶
AddBucket adds a new bucket. Function returns an error if: * the bucket already exists - "bucket already exists" * there's a record with same key - "it's a record"
func (*BoltAPI) AddRecord ¶
AddRecord adds a new record. Function returns an error if: * there's a bucket with same key - "it's a bucket" * the record already exists - "record already exists"
func (*BoltAPI) DeleteBucket ¶
DeleteBucket deletes a bucket. Function returns an error if: * it's a record, not bucket - "it's a record" * there's no such bucket - "there's no such bucket"
func (*BoltAPI) DeleteRecord ¶
DeleteRecord deletes a record Function returns an error if: * it's a bucket, nor record - "it's a bucket" * there's no such record - "there's no such record"
func (*BoltAPI) EditBucketName ¶
EditBucketName renames buckets Process: * firstly, data of a bucket is copied to memory (it is a tree); * secondary, bucket with old name is deleted, bucket with new name is created; * thirdly, the data from memory is copied to the new bucket. Copying works recursively.
func (*BoltAPI) EditRecord ¶
EditRecord edits a record Function returns an error if: * there's a bucket with key == oldKey - "it's a bucket" * there's no record with key == oldKey - "there's no such record" * there's a bucket with key == newKey - "there's a bucket with key == newKey" * there's a record with key == newKey - "there's a record with key == newKey"
func (*BoltAPI) GetCurrent ¶
GetCurrent returns records from current bucket
func (*BoltAPI) NextRecords ¶
NextRecords return next part of records and bool, which shows is there next records
func (*BoltAPI) PrevRecords ¶
PrevRecords return prev part of records and bool, which shows is there previous records
type Data ¶
type Data struct { Records []Record PrevBucket bool PrevRecords bool NextRecords bool RecordsAmount int Path string }
Data serves for returning