Documentation
¶
Index ¶
- Variables
- type Batch
- type YStore
- func (store *YStore) Batch() *Batch
- func (store *YStore) Collections() ([]string, error)
- func (store *YStore) Delete(collection, key string) error
- func (store *YStore) DeleteCollection(collection string) error
- func (store *YStore) Drop() error
- func (store *YStore) Dump() (map[string]map[string]string, error)
- func (store *YStore) Read(collection, key string) (string, error)
- func (store *YStore) ReadAll(collection string) ([]string, error)
- func (store *YStore) SetComment(comment string) error
- func (store *YStore) Write(collection, key, value string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorInvalidCollectionName is returned when a collection param is an empty string ErrorInvalidCollectionName = errors.New("No collection name provided") // ErrorInvalidKeyName is returned when a key param is an empty string ErrorInvalidKeyName = errors.New("No key name provided") // ErrorInvalidValue is returned when a key param is an empty string ErrorInvalidValue = errors.New("No value provided, if you are trying to delete the key please use Delete()") // ErrorCollectionNotFound is returned when trying to read a non exitant collection ErrorCollectionNotFound = errors.New("collection not found") // ErrorKeyNotFound is returned when trying to read a non exitant key ErrorKeyNotFound = errors.New("key not found") )
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch handles multiple writes without a write to the disk so that many values can be written at a single time
type YStore ¶
type YStore struct {
// contains filtered or unexported fields
}
YStore is the struct that handles all interaction with the datastore.
func New ¶
New will create and return a new YStore. A error will be returned if the store already exists and contains invalid data.
func (*YStore) Batch ¶
Batch will return a batch object for this store that can be used to write multiple values ona single file write.
func (*YStore) Collections ¶
Collections will return a string array of all the collections in the datastore. Collections will only ever return an error if the datastore is corrupt.
func (*YStore) Delete ¶
Delete will remove a key/value from the collection in the data store. An error will be returned if the collection cannot be found or the change cannot be persisted.
func (*YStore) DeleteCollection ¶
DeleteCollection will remove the collection from the database. DeleteCollection will return an error if the change cannot be persisted.
func (*YStore) Drop ¶
Drop will clear the data cache as well as remove the file on the disk that acts as the datastore. This will completely clear the datastore.
func (*YStore) Read ¶
Read will read and return the value from the datastore for the provided collection key. Read requires that the collection and key are not empty strings otherwise an error will be returned. If the collection or key does not exist, an error will be returned.
func (*YStore) ReadAll ¶
ReadAll will return a string array of all the keys in a collections. ReadAll will return an error if the collection does not exist or the collection parameter is an empty string.
func (*YStore) SetComment ¶
SetComment will set a comment that will be prepended to the file.