varasto: github.com/function61/varasto/pkg/blorm Index | Files

package blorm

import "github.com/function61/varasto/pkg/blorm"

"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

Package Files

indices.go interface.go simplerepo.go

Variables

var (
    ErrNotFound       = errors.New("database: record not found")
    ErrBucketNotFound = errors.New("bucket not found")
    StopIteration     = errors.New("blorm: stop iteration")
)
var (
    StartFromFirst = []byte("")
)

func NewRangeIndex Uses

func NewRangeIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}, index func(sortKey []byte))) rangeIndexApi

func NewSetIndex Uses

func NewSetIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}) bool) setIndexApi

func NewValueIndex Uses

func NewValueIndex(name string, repo *SimpleRepository, memberEvaluator func(record interface{}, push func(partition []byte))) byValueIndexApi

type Index Uses

type Index interface {
    // contains filtered or unexported methods
}

type Repository Uses

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 Uses

type SimpleRepository struct {
    // contains filtered or unexported fields
}

func NewSimpleRepo Uses

func NewSimpleRepo(bucketName string, allocator func() interface{}, idExtractor func(interface{}) []byte) *SimpleRepository

func (*SimpleRepository) Alloc Uses

func (r *SimpleRepository) Alloc() interface{}

func (*SimpleRepository) Bootstrap Uses

func (r *SimpleRepository) Bootstrap(tx *bbolt.Tx) error

func (*SimpleRepository) Delete Uses

func (r *SimpleRepository) Delete(record interface{}, tx *bbolt.Tx) error

func (*SimpleRepository) Each Uses

func (r *SimpleRepository) Each(fn func(record interface{}) error, tx *bbolt.Tx) error

func (*SimpleRepository) EachFrom Uses

func (r *SimpleRepository) EachFrom(from []byte, fn func(record interface{}) error, tx *bbolt.Tx) error

func (*SimpleRepository) OpenByPrimaryKey Uses

func (r *SimpleRepository) OpenByPrimaryKey(id []byte, record interface{}, tx *bbolt.Tx) error

func (*SimpleRepository) Update Uses

func (r *SimpleRepository) Update(record interface{}, tx *bbolt.Tx) error

Package blorm imports 5 packages (graph) and is imported by 4 packages. Updated 2020-09-24. Refresh now. Tools for package owners.