blorm

package
v0.0.0-...-ea0be71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

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

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 Index

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

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) Bootstrap

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

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) EachFrom

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

func (*SimpleRepository) OpenByPrimaryKey

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

func (*SimpleRepository) Update

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL