Documentation
¶
Overview ¶
"Bolt Light ORM", doesn't do much else than persist structs into Bolt.. this was born because: https://github.com/asdine/storm/issues/222#issuecomment-472791001
Warning: don't Each() and Delete() at the same time. Deletion messes with the iteration
order somehow, and I observed half of the records was deleted when I tried to delete all.
Index ¶
- Variables
- func NewRangeIndex(name string, repo *SimpleRepository, ...) rangeIndexApi
- func NewSetIndex(name string, repo *SimpleRepository, ...) setIndexApi
- func NewValueIndex(name string, repo *SimpleRepository, ...) byValueIndexApi
- type Index
- type Repository
- type SimpleRepository
- func (r *SimpleRepository) Alloc() interface{}
- func (r *SimpleRepository) Bootstrap(tx *bbolt.Tx) error
- func (r *SimpleRepository) Delete(record interface{}, tx *bbolt.Tx) error
- func (r *SimpleRepository) Each(fn func(record interface{}) error, tx *bbolt.Tx) error
- func (r *SimpleRepository) EachFrom(from []byte, fn func(record interface{}) error, tx *bbolt.Tx) error
- func (r *SimpleRepository) OpenByPrimaryKey(id []byte, record interface{}, tx *bbolt.Tx) error
- func (r *SimpleRepository) Update(record interface{}, tx *bbolt.Tx) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("database: record not found") ErrBucketNotFound = errors.New("bucket not found") StopIteration = errors.New("blorm: stop iteration") )
View Source
var (
StartFromFirst = []byte("")
)
Functions ¶
func NewRangeIndex ¶
func NewRangeIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}, index func(sortKey []byte))) rangeIndexApi
func NewSetIndex ¶
func NewSetIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}) bool) setIndexApi
func NewValueIndex ¶
func NewValueIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}, push func(partition []byte))) byValueIndexApi
Types ¶
type Repository ¶
type Repository interface { Bootstrap(tx *bbolt.Tx) error // returns ErrNotFound if record not found // returns ErrBucketNotFound if bootstrap not done for bucket OpenByPrimaryKey(id []byte, record interface{}, tx *bbolt.Tx) error Update(record interface{}, tx *bbolt.Tx) error Delete(record interface{}, tx *bbolt.Tx) error // return blorm.StopIteration from "fn" to stop iteration. that error is not returned // to the API caller Each(fn func(record interface{}) error, tx *bbolt.Tx) error // rules of Each() also apply here EachFrom(from []byte, fn func(record interface{}) error, tx *bbolt.Tx) error Alloc() interface{} }
type SimpleRepository ¶
type SimpleRepository struct {
// contains filtered or unexported fields
}
func NewSimpleRepo ¶
func NewSimpleRepo(bucketName string, allocator func() interface{}, idExtractor func(interface{}) []byte) *SimpleRepository
func (*SimpleRepository) Alloc ¶
func (r *SimpleRepository) Alloc() interface{}
func (*SimpleRepository) Delete ¶
func (r *SimpleRepository) Delete(record interface{}, tx *bbolt.Tx) error
func (*SimpleRepository) Each ¶
func (r *SimpleRepository) Each(fn func(record interface{}) error, tx *bbolt.Tx) error
func (*SimpleRepository) OpenByPrimaryKey ¶
func (r *SimpleRepository) OpenByPrimaryKey(id []byte, record interface{}, tx *bbolt.Tx) error
Click to show internal directories.
Click to hide internal directories.