boltz

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 24 Imported by: 48

Documentation

Index

Constants

View Source
const (
	FieldId             = "id"
	FieldCreatedAt      = "createdAt"
	FieldUpdatedAt      = "updatedAt"
	FieldTags           = "tags"
	FieldIsSystemEntity = "isSystem"
)
View Source
const (
	Metadata   = "meta"
	SnapshotId = "snapshotId"
)
View Source
const (
	CascadeNone         = 1
	CascadeDelete       = 2
	CascadeCreateUpdate = 3
)
View Source
const (
	TestEntityTypeChild  = "child"
	TestEntityTypeParent = "parent"
)
View Source
const (
	IndexesBucket = "indexes"
)
View Source
const (
	ListSizeKeyName = "__list__size__36484231-110c-4767-afe2-01b6e3db107a"
)
View Source
const MaxLinkedSetKeySize = 4096
View Source
const (
	SortMax = 5
)

Variables

This section is empty.

Functions

func BytesToBool

func BytesToBool(value []byte) *bool

func BytesToDatetime

func BytesToDatetime(buf []byte, name string) *time.Time

func BytesToFloat64

func BytesToFloat64(buf []byte) *float64

func BytesToInt32

func BytesToInt32(buf []byte) *int32

func BytesToInt64

func BytesToInt64(buf []byte) *int64

func BytesToString

func BytesToString(buf []byte) *string

func DecodeNext

func DecodeNext(val []byte) ([]byte, []byte, error)

func DecodeStringSlice

func DecodeStringSlice(compoundKey []byte) ([]string, error)

func DumpBoltDb

func DumpBoltDb(tx *bbolt.Tx)

func DumpBucket added in v0.1.45

func DumpBucket(tx *bbolt.Tx, path ...string)

func EncodeByteSlice

func EncodeByteSlice(value []byte) ([]byte, error)

func EncodeStringSlice

func EncodeStringSlice(values []string) ([]byte, error)

func FieldToBool

func FieldToBool(fieldType FieldType, value []byte) *bool

func FieldToDatetime

func FieldToDatetime(fieldType FieldType, value []byte, name string) *time.Time

func FieldToFloat64

func FieldToFloat64(fieldType FieldType, value []byte) *float64

func FieldToInt32

func FieldToInt32(fieldType FieldType, value []byte) *int32

func FieldToInt64

func FieldToInt64(fieldType FieldType, value []byte) *int64

func FieldToString

func FieldToString(fieldType FieldType, value []byte) *string

func GetSingularEntityType

func GetSingularEntityType(entityType string) string

func Int32ToBytes

func Int32ToBytes(value int32) []byte

func IsErrNotFoundErr

func IsErrNotFoundErr(err error) bool

func IsReferenceExistsError

func IsReferenceExistsError(err error) bool

func IsUniqueIndexDuplicateError

func IsUniqueIndexDuplicateError(err error) bool

func NewBoltCursor

func NewBoltCursor(cursor *bbolt.Cursor, forward bool) ast.SeekableSetCursor

func NewForwardBoltCursor

func NewForwardBoltCursor(cursor *bbolt.Cursor) ast.SeekableSetCursor

func NewNotFoundError

func NewNotFoundError(entityType, field, id string) error

func NewReferenceByIdError

func NewReferenceByIdError(localType, localId, remoteType, remoteId, remoteField string) error

func NewReferenceByIdsError

func NewReferenceByIdsError(localType, localId, remoteType string, remoteIds []string, remoteField string) error

func NewReverseBoltCursor

func NewReverseBoltCursor(cursor *bbolt.Cursor) ast.SeekableSetCursor

func NewTypedForwardBoltCursor

func NewTypedForwardBoltCursor(cursor *bbolt.Cursor, fieldType FieldType) ast.SeekableSetCursor

func NewTypedReverseBoltCursor

func NewTypedReverseBoltCursor(cursor *bbolt.Cursor, fieldType FieldType) ast.SeekableSetCursor

func PrependFieldType

func PrependFieldType(fieldType FieldType, value []byte) []byte

func Traverse

func Traverse(traversable Traversable, basePath string, visitor BoltVisitor)

func ValidateDeleted

func ValidateDeleted(tx *bbolt.Tx, id string, ignorePaths ...string) error

func ValidateSymbolsArePublic

func ValidateSymbolsArePublic(query ast.Query, store Store) error

Types

type BaseBoltCursor

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

func (*BaseBoltCursor) Current

func (f *BaseBoltCursor) Current() []byte

func (*BaseBoltCursor) IsValid

func (f *BaseBoltCursor) IsValid() bool

type BaseExtEntity

type BaseExtEntity struct {
	Id        string                 `json:"id"`
	CreatedAt time.Time              `json:"createdAt"`
	UpdatedAt time.Time              `json:"updatedAt"`
	Tags      map[string]interface{} `json:"tags"`
	IsSystem  bool                   `json:"isSystem"`
	Migrate   bool                   `json:"-"`
}

func NewExtEntity

func NewExtEntity(id string, tags map[string]interface{}) *BaseExtEntity

func (*BaseExtEntity) CreateBaseValues

func (entity *BaseExtEntity) CreateBaseValues(ctx *PersistContext)

func (*BaseExtEntity) GetCreatedAt

func (entity *BaseExtEntity) GetCreatedAt() time.Time

func (*BaseExtEntity) GetId

func (entity *BaseExtEntity) GetId() string

func (*BaseExtEntity) GetTags

func (entity *BaseExtEntity) GetTags() map[string]interface{}

func (*BaseExtEntity) GetUpdatedAt

func (entity *BaseExtEntity) GetUpdatedAt() time.Time

func (*BaseExtEntity) IsSystemEntity

func (entity *BaseExtEntity) IsSystemEntity() bool

func (*BaseExtEntity) LoadBaseValues

func (entity *BaseExtEntity) LoadBaseValues(bucket *TypedBucket)

func (*BaseExtEntity) SetBaseValues

func (entity *BaseExtEntity) SetBaseValues(ctx *PersistContext)

func (*BaseExtEntity) SetCreatedAt

func (entity *BaseExtEntity) SetCreatedAt(createdAt time.Time)

func (*BaseExtEntity) SetId

func (entity *BaseExtEntity) SetId(id string)

func (*BaseExtEntity) SetTags

func (entity *BaseExtEntity) SetTags(tags map[string]interface{})

func (*BaseExtEntity) SetUpdatedAt

func (entity *BaseExtEntity) SetUpdatedAt(updatedAt time.Time)

func (*BaseExtEntity) UpdateBaseValues

func (entity *BaseExtEntity) UpdateBaseValues(ctx *PersistContext)

type BaseStore

type BaseStore[E Entity] struct {
	Indexer
	// contains filtered or unexported fields
}

func NewBaseStore

func NewBaseStore[E Entity](definition StoreDefinition[E]) *BaseStore[E]

func (*BaseStore[E]) AddEntityConstraint added in v0.2.0

func (store *BaseStore[E]) AddEntityConstraint(constraint EntityConstraint[E])

func (*BaseStore[E]) AddEntityEventListener added in v0.2.0

func (store *BaseStore[E]) AddEntityEventListener(listener EntityEventListener[E], changeType EntityEventType, changeTypes ...EntityEventType)

func (*BaseStore[E]) AddEntityEventListenerF added in v0.2.0

func (store *BaseStore[E]) AddEntityEventListenerF(listener func(E), changeType EntityEventType, changeTypes ...EntityEventType)

func (*BaseStore[E]) AddEntityIdListener added in v0.2.0

func (store *BaseStore[E]) AddEntityIdListener(listener func(string), changeType EntityEventType, changeTypes ...EntityEventType)

func (*BaseStore[E]) AddExtEntitySymbols

func (store *BaseStore[E]) AddExtEntitySymbols()

func (*BaseStore[E]) AddFkSetSymbol

func (store *BaseStore[E]) AddFkSetSymbol(name string, listStore Store) EntitySetSymbol

func (*BaseStore[E]) AddFkSymbol

func (store *BaseStore[E]) AddFkSymbol(name string, linkedStore Store, prefix ...string) EntitySymbol

func (*BaseStore[E]) AddFkSymbolWithKey

func (store *BaseStore[E]) AddFkSymbolWithKey(name string, key string, linkedStore Store, prefix ...string) EntitySymbol

func (*BaseStore[E]) AddIdSymbol

func (store *BaseStore[E]) AddIdSymbol(name string, nodeType ast.NodeType) EntitySymbol

func (*BaseStore[E]) AddLinkCollection

func (store *BaseStore[E]) AddLinkCollection(local EntitySymbol, remote EntitySymbol) LinkCollection

func (*BaseStore[E]) AddListener added in v0.2.0

func (store *BaseStore[E]) AddListener(listener func(Entity), changeType EntityEventType, changeTypes ...EntityEventType)

func (*BaseStore[E]) AddMapSymbol

func (store *BaseStore[E]) AddMapSymbol(name string, nodeType ast.NodeType, key string, prefix ...string)

func (*BaseStore[E]) AddPublicSetSymbol

func (store *BaseStore[E]) AddPublicSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol

func (*BaseStore[E]) AddRefCountedLinkCollection

func (store *BaseStore[E]) AddRefCountedLinkCollection(local EntitySymbol, remote EntitySymbol) RefCountedLinkCollection

func (*BaseStore[E]) AddSetSymbol

func (store *BaseStore[E]) AddSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol

func (*BaseStore[E]) AddSymbol

func (store *BaseStore[E]) AddSymbol(name string, nodeType ast.NodeType, prefix ...string) EntitySymbol

func (*BaseStore[E]) AddSymbolWithKey

func (store *BaseStore[E]) AddSymbolWithKey(name string, nodeType ast.NodeType, key string, prefix ...string) EntitySymbol

func (*BaseStore[E]) AddUntypedEntityConstraint added in v0.2.0

func (store *BaseStore[E]) AddUntypedEntityConstraint(constraint UntypedEntityConstraint)

func (*BaseStore[E]) CheckIntegrity

func (store *BaseStore[E]) CheckIntegrity(ctx MutateContext, fix bool, errorSink func(err error, fixed bool)) error

func (*BaseStore[E]) Create

func (store *BaseStore[E]) Create(ctx MutateContext, entity E) error

Create stores a new entity in the datastore

Creates must be called on the top level, so we don't need to worry about created being called on a parent store.

func (*BaseStore[E]) DeleteById

func (store *BaseStore[E]) DeleteById(ctx MutateContext, id string) error

func (*BaseStore[E]) DeleteWhere

func (store *BaseStore[E]) DeleteWhere(ctx MutateContext, query string) error

func (*BaseStore[E]) Extended

func (store *BaseStore[E]) Extended() *BaseStore[E]

func (*BaseStore[E]) FindById added in v0.2.0

func (store *BaseStore[E]) FindById(tx *bbolt.Tx, id string) (E, bool, error)

func (*BaseStore[E]) FindMatching

func (*BaseStore[E]) FindMatching(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

func (*BaseStore[E]) FindMatchingAnyOf

func (*BaseStore[E]) FindMatchingAnyOf(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

func (*BaseStore[E]) GetEntitiesBucket

func (store *BaseStore[E]) GetEntitiesBucket(tx *bbolt.Tx) *TypedBucket

func (*BaseStore[E]) GetEntityBucket

func (store *BaseStore[E]) GetEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket

func (*BaseStore[E]) GetEntityReflectType added in v0.2.0

func (store *BaseStore[E]) GetEntityReflectType() reflect.Type

func (*BaseStore[E]) GetEntityStrategy added in v0.2.0

func (store *BaseStore[E]) GetEntityStrategy() EntityStrategy[E]

func (*BaseStore[E]) GetEntityType

func (store *BaseStore[E]) GetEntityType() string

func (*BaseStore[E]) GetLinkCollection

func (store *BaseStore[E]) GetLinkCollection(name string) LinkCollection

func (*BaseStore[E]) GetParentStore

func (store *BaseStore[E]) GetParentStore() Store

func (*BaseStore[E]) GetPublicSymbols

func (store *BaseStore[E]) GetPublicSymbols() []string

func (*BaseStore[E]) GetRefCountedLinkCollection

func (store *BaseStore[E]) GetRefCountedLinkCollection(name string) RefCountedLinkCollection

func (*BaseStore[E]) GetRelatedEntitiesCursor

func (store *BaseStore[E]) GetRelatedEntitiesCursor(tx *bbolt.Tx, id string, field string, forward bool) ast.SetCursor

func (*BaseStore[E]) GetRelatedEntitiesIdList

func (store *BaseStore[E]) GetRelatedEntitiesIdList(tx *bbolt.Tx, id string, field string) []string

func (*BaseStore[E]) GetRootPath added in v0.1.17

func (store *BaseStore[E]) GetRootPath() []string

func (*BaseStore[E]) GetSetSymbolTypes

func (store *BaseStore[E]) GetSetSymbolTypes(name string) ast.SymbolTypes

func (*BaseStore[E]) GetSingularEntityType

func (store *BaseStore[E]) GetSingularEntityType() string

func (*BaseStore[E]) GetSymbol

func (store *BaseStore[E]) GetSymbol(name string) EntitySymbol

GetSymbol returns the symbol for the given name, or nil if the symbol doesn't exist

func (*BaseStore[E]) GetSymbolType

func (store *BaseStore[E]) GetSymbolType(name string) (ast.NodeType, bool)

func (*BaseStore[E]) GrantSymbols

func (store *BaseStore[E]) GrantSymbols(child ConfigurableStore)

func (*BaseStore[E]) InitImpl

func (store *BaseStore[E]) InitImpl(impl EntityStore[E])

func (*BaseStore[E]) IsChildStore

func (store *BaseStore[E]) IsChildStore() bool

func (*BaseStore[E]) IsEntityPresent

func (store *BaseStore[E]) IsEntityPresent(tx *bbolt.Tx, id string) bool

func (*BaseStore[E]) IsEntityRelated

func (store *BaseStore[E]) IsEntityRelated(tx *bbolt.Tx, id string, field string, relatedEntityId string) bool

func (*BaseStore[E]) IsExtended

func (store *BaseStore[E]) IsExtended() bool

func (*BaseStore[E]) IsPublicSymbol added in v0.1.21

func (store *BaseStore[E]) IsPublicSymbol(symbol string) bool

func (*BaseStore[E]) IsSet

func (store *BaseStore[E]) IsSet(name string) (bool, bool)

func (*BaseStore[E]) IterateIds

func (store *BaseStore[E]) IterateIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

func (*BaseStore[E]) IterateValidIds

func (store *BaseStore[E]) IterateValidIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

func (*BaseStore[E]) IteratorMatchingAllOf

func (*BaseStore[E]) IteratorMatchingAllOf(readIndex SetReadIndex, values []string) ast.SetCursorProvider

func (*BaseStore[E]) IteratorMatchingAnyOf

func (*BaseStore[E]) IteratorMatchingAnyOf(readIndex SetReadIndex, values []string) ast.SetCursorProvider

func (*BaseStore[E]) LoadById added in v0.2.0

func (store *BaseStore[E]) LoadById(tx *bbolt.Tx, id string) (E, error)

func (*BaseStore[E]) LoadEntity added in v0.2.0

func (store *BaseStore[E]) LoadEntity(tx *bbolt.Tx, id string, entity E) (bool, error)

func (*BaseStore[E]) MakeSymbolPublic

func (store *BaseStore[E]) MakeSymbolPublic(symbol string)

func (*BaseStore[E]) MapSymbol

func (store *BaseStore[E]) MapSymbol(name string, mapper SymbolMapper)

func (*BaseStore[E]) NewEntitySymbol

func (store *BaseStore[E]) NewEntitySymbol(name string, nodeType ast.NodeType) EntitySymbol

func (*BaseStore[E]) NewScanner

func (store *BaseStore[E]) NewScanner(sort []ast.SortField) Scanner

func (*BaseStore[E]) NewStoreEntity added in v0.2.0

func (store *BaseStore[E]) NewStoreEntity() E

func (*BaseStore[E]) QueryIds

func (store *BaseStore[E]) QueryIds(tx *bbolt.Tx, queryString string) ([]string, int64, error)

func (*BaseStore[E]) QueryIdsC

func (store *BaseStore[E]) QueryIdsC(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)

func (*BaseStore[E]) QueryWithCursorC

func (store *BaseStore[E]) QueryWithCursorC(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)

func (*BaseStore[E]) RegisterChildStoreStrategy added in v0.2.0

func (store *BaseStore[E]) RegisterChildStoreStrategy(childStoreStrategy ChildStoreStrategy[E])

func (*BaseStore[E]) Update

func (store *BaseStore[E]) Update(ctx MutateContext, entity E, checker FieldChecker) error

type BoltVisitor

type BoltVisitor interface {
	VisitBucket(path string, key []byte, bucket *bbolt.Bucket) bool
	VisitKeyValue(path string, key, value []byte) bool
}

type CascadeType

type CascadeType int

type Checkable added in v0.2.0

type Checkable interface {
	CheckIntegrity(ctx MutateContext, fix bool, errorSink func(err error, fixed bool)) error
}

A Checkable can be checked for consistency. This could be an index, an FK or something which contains multiple Checkables and can delegate to them

type ChildStoreStrategy added in v0.2.0

type ChildStoreStrategy[E Entity] interface {
	HandleUpdate(ctx MutateContext, entity E, checker FieldChecker) (bool, error)
	HandleDelete(ctx MutateContext, entity E) error
	GetStore() Store
}

ChildStoreStrategy instances are used to allow a parent store to properly delegate to a child store where needed

type ChildStoreUpdateHandler added in v0.2.0

type ChildStoreUpdateHandler[E Entity, C Entity] struct {
	Store  EntityStore[C]
	Mapper func(ctx MutateContext, parent E) (C, bool)
}

func (*ChildStoreUpdateHandler[E, C]) GetStore added in v0.2.0

func (self *ChildStoreUpdateHandler[E, C]) GetStore() Store

func (*ChildStoreUpdateHandler[E, C]) HandleDelete added in v0.2.0

func (self *ChildStoreUpdateHandler[E, C]) HandleDelete(MutateContext, E) error

func (*ChildStoreUpdateHandler[E, C]) HandleUpdate added in v0.2.0

func (self *ChildStoreUpdateHandler[E, C]) HandleUpdate(ctx MutateContext, entity E, checker FieldChecker) (bool, error)

type CommitAction

type CommitAction interface {
	Exec()
}

type ConfigurableStore added in v0.2.0

type ConfigurableStore interface {
	Store
	MapSymbol(name string, wrapper SymbolMapper)
	AddIdSymbol(name string, nodeType ast.NodeType) EntitySymbol
	AddSymbol(name string, nodeType ast.NodeType, path ...string) EntitySymbol
	AddFkSymbol(name string, linkedType Store, path ...string) EntitySymbol
	AddSymbolWithKey(name string, nodeType ast.NodeType, key string, path ...string) EntitySymbol
	AddFkSymbolWithKey(name string, key string, linkedType Store, path ...string) EntitySymbol
	AddMapSymbol(name string, nodeType ast.NodeType, key string, path ...string)
	AddSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol
	AddPublicSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol
	AddFkSetSymbol(name string, linkedType Store) EntitySetSymbol
	NewEntitySymbol(name string, nodeType ast.NodeType) EntitySymbol

	AddExtEntitySymbols()
	MakeSymbolPublic(name string)

	AddLinkCollection(local EntitySymbol, remove EntitySymbol) LinkCollection
	AddRefCountedLinkCollection(local EntitySymbol, remove EntitySymbol) RefCountedLinkCollection
}

ConfigurableStore has all the APIs that store implementations need to configure themselves

type Constrained

type Constrained interface {
	AddConstraint(constraint Constraint)
}

type Constraint

type Constraint interface {
	Checkable
	ProcessBeforeUpdate(ctx *IndexingContext)
	ProcessAfterUpdate(ctx *IndexingContext)
	ProcessBeforeDelete(ctx *IndexingContext)
	Initialize(tx *bbolt.Tx, errorHolder errorz.ErrorHolder)
}

func NewSystemEntityEnforcementConstraint

func NewSystemEntityEnforcementConstraint(store Store) Constraint

type Db

type Db interface {
	io.Closer
	Update(ctx MutateContext, fn func(ctx MutateContext) error) error
	Batch(ctx MutateContext, fn func(ctx MutateContext) error) error
	View(fn func(tx *bbolt.Tx) error) error
	RootBucket(tx *bbolt.Tx) (*bbolt.Bucket, error)

	// Snapshot makes a copy of the bolt file
	Snapshot(tx *bbolt.Tx) error

	// SnapshotToMemory writes a snapshot of the database state to a memory buffer.
	// The snapshot has a UUID generated and stored at rootBucket/snapshotId
	// The snapshot id and snapshot are returned
	SnapshotToMemory() (string, []byte, error)

	// SnapshotToWriter writes a snapshot of the database state to the given writer
	// The snapshot has a UUID generated and stored at rootBucket/snapshotId
	// The snapshot id and snapshot are returned
	SnapshotToWriter(w io.Writer) (string, error)

	// GetSnapshotId returns the id of the last snapshot created/restored
	GetSnapshotId() (*string, error)

	// RestoreSnapshot will replace the existing DB with the given snapshot
	// This operation is not allowed to fail, and will thus panic if the snapshot cannot be restored
	RestoreSnapshot(snapshotData []byte)

	// RestoreFromReader will replace the existing DB with the given snapshot
	// This operation is not allowed to fail, and will thus panic if the snapshot cannot be restored
	RestoreFromReader(snapshot io.Reader)

	// AddRestoreListener adds a callback which will be invoked asynchronously when a snapshot is restored
	AddRestoreListener(listener func())
}

type DbImpl added in v0.1.17

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

func Open added in v0.1.17

func Open(path string, rootBucket string) (*DbImpl, error)

func (*DbImpl) AddRestoreListener added in v0.1.17

func (self *DbImpl) AddRestoreListener(f func())

func (*DbImpl) Batch added in v0.1.17

func (self *DbImpl) Batch(ctx MutateContext, fn func(ctx MutateContext) error) error

func (*DbImpl) Close added in v0.1.17

func (self *DbImpl) Close() error

func (*DbImpl) GetSnapshotId added in v0.1.17

func (self *DbImpl) GetSnapshotId() (*string, error)

func (*DbImpl) Open added in v0.1.17

func (self *DbImpl) Open(path string) error

func (*DbImpl) RestoreFromReader added in v0.1.34

func (self *DbImpl) RestoreFromReader(snapshot io.Reader)

func (*DbImpl) RestoreSnapshot added in v0.1.17

func (self *DbImpl) RestoreSnapshot(snapshot []byte)

func (*DbImpl) RootBucket added in v0.1.17

func (self *DbImpl) RootBucket(tx *bbolt.Tx) (*bbolt.Bucket, error)

func (*DbImpl) Snapshot added in v0.1.17

func (self *DbImpl) Snapshot(tx *bbolt.Tx) error

func (*DbImpl) SnapshotToMemory added in v0.1.17

func (self *DbImpl) SnapshotToMemory() (string, []byte, error)

func (*DbImpl) SnapshotToWriter added in v0.1.32

func (self *DbImpl) SnapshotToWriter(w io.Writer) (string, error)

func (*DbImpl) Stats added in v0.1.17

func (self *DbImpl) Stats() bbolt.Stats

func (*DbImpl) Update added in v0.1.17

func (self *DbImpl) Update(ctx MutateContext, fn func(ctx MutateContext) error) error

func (*DbImpl) View added in v0.1.17

func (self *DbImpl) View(fn func(tx *bbolt.Tx) error) error

type Entity

type Entity interface {
	GetId() string
	SetId(id string)
	GetEntityType() string
}

Entity represents the minimal methods needed for an entity

type EntityChangeState added in v0.2.0

type EntityChangeState[E Entity] struct {
	EventId      string
	EntityId     string
	Ctx          MutateContext
	InitialState E
	FinalState   E

	ChangeType  EntityEventType
	ParentEvent bool
	// contains filtered or unexported fields
}

func (*EntityChangeState[E]) GetChangeType added in v0.2.0

func (self *EntityChangeState[E]) GetChangeType() EntityEventType

func (*EntityChangeState[E]) GetCtx added in v0.2.0

func (self *EntityChangeState[E]) GetCtx() MutateContext

func (*EntityChangeState[E]) GetEntityId added in v0.2.0

func (self *EntityChangeState[E]) GetEntityId() string

func (*EntityChangeState[E]) GetEventId added in v0.2.0

func (self *EntityChangeState[E]) GetEventId() string

func (*EntityChangeState[E]) GetFinalParentEntity added in v0.2.0

func (self *EntityChangeState[E]) GetFinalParentEntity() Entity

func (*EntityChangeState[E]) GetFinalState added in v0.2.0

func (self *EntityChangeState[E]) GetFinalState() Entity

func (*EntityChangeState[E]) GetInitialParentEntity added in v0.2.0

func (self *EntityChangeState[E]) GetInitialParentEntity() Entity

func (*EntityChangeState[E]) GetInitialState added in v0.2.0

func (self *EntityChangeState[E]) GetInitialState() Entity

func (*EntityChangeState[E]) GetStore added in v0.2.0

func (self *EntityChangeState[E]) GetStore() Store

func (*EntityChangeState[E]) IsParentEvent added in v0.2.0

func (self *EntityChangeState[E]) IsParentEvent() bool

func (*EntityChangeState[E]) MarkParentEvent added in v0.2.0

func (self *EntityChangeState[E]) MarkParentEvent()

type EntityConstraint added in v0.2.0

type EntityConstraint[E Entity] interface {
	ProcessPreCommit(state *EntityChangeState[E]) error
	ProcessPostCommit(state *EntityChangeState[E])
}

EntityConstraint implementations allow reacting to entity changes, both pre and post commit

type EntityEventListener added in v0.2.0

type EntityEventListener[E Entity] interface {
	HandleEntityEvent(entity E)
}

EntityEventListener instances will be notified after an entity change has been committed

type EntityEventType added in v0.2.0

type EntityEventType byte
const (
	EntityCreated EntityEventType = 1
	EntityUpdated EntityEventType = 2
	EntityDeleted EntityEventType = 3

	EntityCreatedAsync EntityEventType = 4
	EntityUpdatedAsync EntityEventType = 5
	EntityDeletedAsync EntityEventType = 6
)

func (EntityEventType) IsAsync added in v0.2.0

func (self EntityEventType) IsAsync() bool

func (EntityEventType) IsCreate added in v0.2.0

func (self EntityEventType) IsCreate() bool

func (EntityEventType) IsDelete added in v0.2.0

func (self EntityEventType) IsDelete() bool

func (EntityEventType) IsUpdate added in v0.2.0

func (self EntityEventType) IsUpdate() bool

type EntitySetSymbol

type EntitySetSymbol interface {
	EntitySymbol
	GetRuntimeSymbol() RuntimeEntitySetSymbol
	EvalStringList(tx *bbolt.Tx, key []byte) []string
	Map(tx *bbolt.Tx, key []byte, f func(ctx *MapContext)) error
}

type EntityStore added in v0.2.0

type EntityStore[E Entity] interface {
	Store

	RegisterChildStoreStrategy(childStoreStrategy ChildStoreStrategy[E])

	Create(ctx MutateContext, entity E) error
	Update(ctx MutateContext, entity E, checker FieldChecker) error

	// FindById returns the entity for the given Id and true if the eneity exists. If the entity
	// doesn't exist it returns the default value (usually nil) and a false
	FindById(tx *bbolt.Tx, id string) (E, bool, error)

	// LoadById return the entity for the given Id if it exists, otherwise it returns nil and a
	// RecordNotFoundError
	LoadById(tx *bbolt.Tx, id string) (E, error)
	LoadEntity(tx *bbolt.Tx, id string, entity E) (bool, error)

	GetEntityStrategy() EntityStrategy[E]
	AddEntityConstraint(constraint EntityConstraint[E])
	AddEntityEventListener(listener EntityEventListener[E], changeType EntityEventType, changeTypes ...EntityEventType)
	AddEntityEventListenerF(listener func(E), changeType EntityEventType, changeTypes ...EntityEventType)
}

EntityStore extends Store with the methods that need concrete implementation types

type EntityStrategy added in v0.2.0

type EntityStrategy[E Entity] interface {
	NewEntity() E
	FillEntity(entity E, bucket *TypedBucket)
	PersistEntity(entity E, ctx *PersistContext)
}

type EntitySymbol

type EntitySymbol interface {
	GetStore() Store
	GetLinkedType() Store
	GetPath() []string
	GetType() ast.NodeType
	GetName() string
	IsSet() bool
	Eval(tx *bbolt.Tx, rowId []byte) (FieldType, []byte)
}

type ExtEntity

type ExtEntity interface {
	Entity
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetTags() map[string]interface{}
	IsSystemEntity() bool

	SetCreatedAt(createdAt time.Time)
	SetUpdatedAt(updatedAt time.Time)
	SetTags(tags map[string]interface{})
}

ExtEntity extends Entity with common additional attributes

type FieldChecker

type FieldChecker interface {
	IsUpdated(string) bool
}

func NewMappedFieldChecker

func NewMappedFieldChecker(checker FieldChecker, mappings map[string]string) FieldChecker

type FieldType

type FieldType byte
const (
	TypeBool    FieldType = 1
	TypeInt32   FieldType = 2
	TypeInt64   FieldType = 3
	TypeFloat64 FieldType = 4
	TypeString  FieldType = 5
	TypeTime    FieldType = 6
	TypeNil     FieldType = 7
)

func GetTypeAndValue

func GetTypeAndValue(bytes []byte) (FieldType, []byte)

type FieldTypeAndValue

type FieldTypeAndValue struct {
	FieldType
	Value []byte
}

type ForwardBoltCursor

type ForwardBoltCursor struct {
	BaseBoltCursor
}

func (*ForwardBoltCursor) Next

func (f *ForwardBoltCursor) Next()

func (*ForwardBoltCursor) Seek

func (f *ForwardBoltCursor) Seek(val []byte)

type Indexer

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

func NewIndexer

func NewIndexer(basePath ...string) *Indexer

func (*Indexer) AddConstraint

func (indexer *Indexer) AddConstraint(constraint Constraint)

func (*Indexer) AddFkConstraint

func (indexer *Indexer) AddFkConstraint(symbol EntitySymbol, nullable bool, cascade CascadeType)

func (*Indexer) AddFkIndex

func (indexer *Indexer) AddFkIndex(symbol EntitySymbol, fkSymbol EntitySetSymbol)

func (*Indexer) AddNullableFkIndex

func (indexer *Indexer) AddNullableFkIndex(symbol EntitySymbol, fkSymbol EntitySetSymbol)

func (*Indexer) AddNullableUniqueIndex

func (indexer *Indexer) AddNullableUniqueIndex(symbol EntitySymbol) ReadIndex

func (*Indexer) AddSetIndex

func (indexer *Indexer) AddSetIndex(symbol EntitySetSymbol) SetReadIndex

func (*Indexer) AddUniqueIndex

func (indexer *Indexer) AddUniqueIndex(symbol EntitySymbol) ReadIndex

func (*Indexer) InitializeIndexes

func (indexer *Indexer) InitializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder)

type IndexingContext

type IndexingContext struct {
	Parent *IndexingContext
	*Indexer
	IsCreate   bool
	Ctx        MutateContext
	RowId      []byte
	ErrHolder  errorz.ErrorHolder
	AtomStates map[Constraint][]byte
	SetStates  map[Constraint][]FieldTypeAndValue
}

func (*IndexingContext) PopState

func (ctx *IndexingContext) PopState(constraint Constraint) *FieldTypeAndValue

func (*IndexingContext) PopStateBool

func (ctx *IndexingContext) PopStateBool(constraint Constraint) bool

func (*IndexingContext) PopStateString

func (ctx *IndexingContext) PopStateString(constraint Constraint) string

func (*IndexingContext) ProcessAfterUpdate

func (ctx *IndexingContext) ProcessAfterUpdate()

func (*IndexingContext) ProcessBeforeDelete

func (ctx *IndexingContext) ProcessBeforeDelete()

func (*IndexingContext) ProcessBeforeUpdate

func (ctx *IndexingContext) ProcessBeforeUpdate()

func (*IndexingContext) PushState

func (ctx *IndexingContext) PushState(constraint Constraint, fieldType FieldType, fieldValue []byte)

func (*IndexingContext) Tx

func (ctx *IndexingContext) Tx() *bbolt.Tx

type LinkCollection

type LinkCollection interface {
	Checkable
	AddLinks(tx *bbolt.Tx, id string, keys ...string) error
	AddLink(tx *bbolt.Tx, id []byte, key []byte) (bool, error)
	RemoveLinks(tx *bbolt.Tx, id string, keys ...string) error
	RemoveLink(tx *bbolt.Tx, id []byte, keys []byte) (bool, error)
	SetLinks(tx *bbolt.Tx, id string, keys []string) error
	GetLinks(tx *bbolt.Tx, id string) []string
	IterateLinks(tx *bbolt.Tx, id []byte) ast.SeekableSetCursor
	IsLinked(tx *bbolt.Tx, id, relatedId []byte) bool
	EntityDeleted(tx *bbolt.Tx, id string) error
	GetFieldSymbol() EntitySymbol
	GetLinkedSymbol() EntitySymbol
}

type LinkedSetSymbol

type LinkedSetSymbol struct {
	EntitySymbol
}
func (symbol *LinkedSetSymbol) AddCompoundLink(tx *bbolt.Tx, id string, linkIds []string) error
func (symbol *LinkedSetSymbol) AddLink(tx *bbolt.Tx, id []byte, link []byte) error
func (symbol *LinkedSetSymbol) AddLinkS(tx *bbolt.Tx, id string, link string) error

func (*LinkedSetSymbol) IsLinked

func (symbol *LinkedSetSymbol) IsLinked(tx *bbolt.Tx, id []byte, link []byte) bool
func (symbol *LinkedSetSymbol) RemoveCompoundLink(tx *bbolt.Tx, id string, linkIds []string) error
func (symbol *LinkedSetSymbol) RemoveLink(tx *bbolt.Tx, id []byte, link []byte) error

type MapContext

type MapContext struct {
	errorz.ErrorHolderImpl
	// contains filtered or unexported fields
}

func (*MapContext) Delete

func (ctx *MapContext) Delete()

func (*MapContext) Replace

func (ctx *MapContext) Replace(fieldType FieldType, val []byte)

func (*MapContext) ReplaceS

func (ctx *MapContext) ReplaceS(val string)

func (*MapContext) Stop

func (ctx *MapContext) Stop()

func (*MapContext) Type

func (ctx *MapContext) Type() FieldType

func (*MapContext) Value

func (ctx *MapContext) Value() []byte

func (*MapContext) ValueS

func (ctx *MapContext) ValueS() string

type MapFieldChecker

type MapFieldChecker map[string]struct{}

func (MapFieldChecker) IsUpdated

func (m MapFieldChecker) IsUpdated(name string) bool

func (MapFieldChecker) ToSlice

func (m MapFieldChecker) ToSlice() []string

type MappedFieldChecker

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

func (*MappedFieldChecker) IsUpdated

func (f *MappedFieldChecker) IsUpdated(field string) bool

type MigrationManager

type MigrationManager interface {
	GetComponentVersion(component string) (int, error)
	Migrate(component string, targetVersion int, migrator Migrator) error
}

func NewMigratorManager

func NewMigratorManager(db Db) MigrationManager

type MigrationStep

type MigrationStep struct {
	errorz.ErrorHolderImpl
	Component      string
	Ctx            MutateContext
	CurrentVersion int
}

type Migrator

type Migrator func(step *MigrationStep) int

type MutateContext

type MutateContext interface {
	Tx() *bbolt.Tx
	AddPreCommitAction(func(ctx MutateContext) error)

	AddCommitAction(func())

	IsSystemContext() bool
	GetSystemContext() MutateContext
	Context() context.Context
	UpdateContext(func(ctx context.Context) context.Context) MutateContext
	// contains filtered or unexported methods
}

func NewMutateContext

func NewMutateContext(context context.Context) MutateContext

func NewSystemMutateContext

func NewSystemMutateContext(ctx MutateContext) MutateContext

func NewTxMutateContext added in v0.2.0

func NewTxMutateContext(context context.Context, tx *bbolt.Tx) MutateContext

type NamedExtEntity

type NamedExtEntity interface {
	ExtEntity
	GetName() string
}

NamedExtEntity extends ExtEntity with a Name attribute

type NotNilStringMapper

type NotNilStringMapper struct {
}

func (NotNilStringMapper) Map

func (n NotNilStringMapper) Map(_ EntitySymbol, fieldType FieldType, value []byte) (FieldType, []byte)

type PersistContext

type PersistContext struct {
	MutateContext
	Id           string
	Store        Store
	Bucket       *TypedBucket
	FieldChecker FieldChecker
	IsCreate     bool
}

A PersistContext wraps all the state needed when persisting an entity to a store

func (*PersistContext) GetAndSetString

func (ctx *PersistContext) GetAndSetString(field string, value string) (*string, bool)

func (*PersistContext) GetAndSetStringList

func (ctx *PersistContext) GetAndSetStringList(field string, value []string) ([]string, bool)

func (*PersistContext) GetParentContext

func (ctx *PersistContext) GetParentContext() *PersistContext

func (*PersistContext) ProceedWithSet

func (ctx *PersistContext) ProceedWithSet(field string) bool

func (*PersistContext) SetBool

func (ctx *PersistContext) SetBool(field string, value bool)

func (*PersistContext) SetInt32

func (ctx *PersistContext) SetInt32(field string, value int32)

func (*PersistContext) SetInt64

func (ctx *PersistContext) SetInt64(field string, value int64)

func (*PersistContext) SetLinkedIds

func (ctx *PersistContext) SetLinkedIds(field string, value []string)

func (*PersistContext) SetMap

func (ctx *PersistContext) SetMap(field string, value map[string]interface{})

func (*PersistContext) SetRequiredString

func (ctx *PersistContext) SetRequiredString(field string, value string)

func (*PersistContext) SetString

func (ctx *PersistContext) SetString(field string, value string)

func (*PersistContext) SetStringList

func (ctx *PersistContext) SetStringList(field string, value []string)

func (*PersistContext) SetStringP

func (ctx *PersistContext) SetStringP(field string, value *string)

func (*PersistContext) SetTimeP

func (ctx *PersistContext) SetTimeP(field string, value *time.Time)

func (*PersistContext) WithFieldOverrides

func (ctx *PersistContext) WithFieldOverrides(overrides map[string]string)

type ReadIndex

type ReadIndex interface {
	Read(tx *bbolt.Tx, val []byte) []byte
}

type RecordNotFoundError

type RecordNotFoundError struct {
	EntityType string
	Field      string
	Id         string
}

func (*RecordNotFoundError) Error

func (err *RecordNotFoundError) Error() string

type RefCountedLinkCollection

type RefCountedLinkCollection interface {
	IncrementLinkCount(tx *bbolt.Tx, id []byte, key []byte) (int, error)
	DecrementLinkCount(tx *bbolt.Tx, id []byte, key []byte) (int, error)
	GetLinkCount(tx *bbolt.Tx, id []byte, relatedId []byte) *int32
	GetLinkCounts(tx *bbolt.Tx, id []byte, relatedId []byte) (*int32, *int32)
	SetLinkCount(tx *bbolt.Tx, id []byte, key []byte, count int) (*int32, *int32, error)
	EntityDeleted(tx *bbolt.Tx, id string) error
	IterateLinks(tx *bbolt.Tx, id []byte, forward bool) ast.SeekableSetCursor
	GetFieldSymbol() EntitySymbol
	GetLinkedSymbol() EntitySymbol
}

type RefCountedLinkedSetSymbol

type RefCountedLinkedSetSymbol struct {
	EntitySymbol
}

type ReferenceExistsError

type ReferenceExistsError struct {
	LocalType   string
	RemoteType  string
	RemoteField string
	LocalId     string
	RemoteIds   []string
}

ReferenceExistsError is an error returned when an operation cannot be completed due to a referential constraint. Typically, when deleting an entity (called local) that is referenced by another entity (called the remote)

func (*ReferenceExistsError) Error

func (err *ReferenceExistsError) Error() string

type ReverseBoltCursor

type ReverseBoltCursor struct {
	BaseBoltCursor
}

func (*ReverseBoltCursor) Next

func (f *ReverseBoltCursor) Next()

func (*ReverseBoltCursor) Seek

func (f *ReverseBoltCursor) Seek(val []byte)

type Row

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

func (*Row) Compare

func (r *Row) Compare(other llrb.Comparable) int

type RowComparator

type RowComparator interface {
	Compare(rowId1, rowId2 RowCursor) int
}

type RowContext

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

type RowCursor

type RowCursor interface {
	CurrentRow() []byte
	Tx() *bbolt.Tx
}

type RuntimeEntitySetSymbol

type RuntimeEntitySetSymbol interface {
	EntitySymbol
	OpenCursor(tx *bbolt.Tx, rowId []byte) ast.SetCursor
}

type Scanner

type Scanner interface {
	Scan(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)
	ScanCursor(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)
}

type SetChangeListener

type SetChangeListener func(ctx MutateContext, rowId []byte, old []FieldTypeAndValue, new []FieldTypeAndValue, holder errorz.ErrorHolder)

type SetReadIndex

type SetReadIndex interface {
	GetSymbol() EntitySetSymbol
	Read(tx *bbolt.Tx, key []byte, f func(val []byte))
	ReadKeys(tx *bbolt.Tx, f func(val []byte))
	OpenValueCursor(tx *bbolt.Tx, key []byte, forward bool) ast.SetCursor
	OpenKeyCursor(tx *bbolt.Tx, forward bool) ast.SetCursor
	AddListener(listener SetChangeListener)
}

type Store added in v0.2.0

type Store interface {
	ast.SymbolTypes
	Checkable
	Constrained

	GetEntityType() string
	GetSingularEntityType() string
	GetRootPath() []string
	GetEntitiesBucket(tx *bbolt.Tx) *TypedBucket
	GetEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket
	IsChildStore() bool
	IsEntityPresent(tx *bbolt.Tx, id string) bool
	IsExtended() bool

	GetSymbol(name string) EntitySymbol

	GetPublicSymbols() []string
	IsPublicSymbol(symbol string) bool

	FindMatching(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

	GetLinkCollection(name string) LinkCollection
	GetRefCountedLinkCollection(name string) RefCountedLinkCollection

	GetRelatedEntitiesIdList(tx *bbolt.Tx, id string, field string) []string
	GetRelatedEntitiesCursor(tx *bbolt.Tx, id string, field string, forward bool) ast.SetCursor
	IsEntityRelated(tx *bbolt.Tx, id string, field string, relatedEntityId string) bool

	// QueryIds compiles the query and runs it against the store
	QueryIds(tx *bbolt.Tx, query string) ([]string, int64, error)

	// QueryIdsC executes a compile query against the store
	QueryIdsC(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)

	QueryWithCursorC(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)

	IterateIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

	// IterateValidIds skips non-present entities in extended stores
	IterateValidIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

	GetParentStore() Store
	GrantSymbols(child ConfigurableStore)

	DeleteById(ctx MutateContext, id string) error
	DeleteWhere(ctx MutateContext, query string) error

	AddListener(listener func(Entity), changeType EntityEventType, changeTypes ...EntityEventType)
	AddEntityIdListener(listener func(string), changeType EntityEventType, changeTypes ...EntityEventType)
	AddUntypedEntityConstraint(constraint UntypedEntityConstraint)
	GetEntityReflectType() reflect.Type
	// contains filtered or unexported methods
}

Store contains all the methods for interacting with an entity store that don't require knowedge of the concrete entity type.

type StoreDefinition added in v0.2.0

type StoreDefinition[E Entity] struct {
	EntityType      string
	EntityStrategy  EntityStrategy[E]
	BasePath        []string
	Parent          Store
	ParentMapper    func(Entity) Entity
	EntityNotFoundF func(id string) error
}

func (*StoreDefinition[E]) WithBasePath added in v0.2.0

func (self *StoreDefinition[E]) WithBasePath(basePath ...string) *StoreDefinition[E]

type SymbolMapper

type SymbolMapper interface {
	Map(source EntitySymbol, fieldType FieldType, value []byte) (FieldType, []byte)
}

type TestEvent

type TestEvent struct {
	EntityType string
	Entity     Entity
	// contains filtered or unexported fields
}

type TestEventChecker

type TestEventChecker struct {
	*require.Assertions
	// contains filtered or unexported fields
}

func NewTestEventChecker

func NewTestEventChecker(req *require.Assertions) *TestEventChecker

func (*TestEventChecker) AddHandlers

func (self *TestEventChecker) AddHandlers(store Store)

func (*TestEventChecker) RequireEvent

func (self *TestEventChecker) RequireEvent(entityType string, entity Entity, eventType EntityEventType) Entity

func (*TestEventChecker) RequireNoEvent

func (self *TestEventChecker) RequireNoEvent()

type Traversable added in v0.1.45

type Traversable interface {
	Cursor() *bbolt.Cursor
	Bucket(key []byte) *bbolt.Bucket
}

type TypedBucket

type TypedBucket struct {
	*bbolt.Bucket

	*errorz.ErrorHolderImpl
	// contains filtered or unexported fields
}

func ErrBucket

func ErrBucket(err error) *TypedBucket

func GetOrCreatePath

func GetOrCreatePath(tx *bbolt.Tx, path ...string) *TypedBucket

func NewTypedBucket added in v0.2.0

func NewTypedBucket(parent *TypedBucket, bucket *bbolt.Bucket) *TypedBucket

func Path

func Path(tx *bbolt.Tx, path ...string) *TypedBucket

func (*TypedBucket) CheckAndDeleteListEntry

func (bucket *TypedBucket) CheckAndDeleteListEntry(fieldType FieldType, value []byte) (bool, error)

func (*TypedBucket) CheckAndSetListEntry

func (bucket *TypedBucket) CheckAndSetListEntry(fieldType FieldType, value []byte) (bool, error)

func (*TypedBucket) Copy

func (bucket *TypedBucket) Copy(other *TypedBucket, filterF func(path []string) bool) error

func (*TypedBucket) DecrementLinkCount

func (bucket *TypedBucket) DecrementLinkCount(fieldType FieldType, value []byte) (int, error)

func (*TypedBucket) DeleteEntity

func (bucket *TypedBucket) DeleteEntity(id string)

func (*TypedBucket) DeleteListEntry

func (bucket *TypedBucket) DeleteListEntry(fieldType FieldType, value []byte) *TypedBucket

func (*TypedBucket) DeleteValue

func (bucket *TypedBucket) DeleteValue(key []byte) *TypedBucket

func (*TypedBucket) EmptyBucket

func (bucket *TypedBucket) EmptyBucket(name string) (*TypedBucket, error)

func (*TypedBucket) GetAndSetString

func (bucket *TypedBucket) GetAndSetString(name string, value string, fieldChecker FieldChecker) (*string, bool)

func (*TypedBucket) GetAndSetStringList

func (bucket *TypedBucket) GetAndSetStringList(name string, value []string, fieldChecker FieldChecker) ([]string, bool)

func (*TypedBucket) GetBool

func (bucket *TypedBucket) GetBool(name string) *bool

func (*TypedBucket) GetBoolWithDefault

func (bucket *TypedBucket) GetBoolWithDefault(name string, defaultValue bool) bool

func (*TypedBucket) GetBucket

func (bucket *TypedBucket) GetBucket(name string) *TypedBucket

func (*TypedBucket) GetBucketByKey

func (bucket *TypedBucket) GetBucketByKey(key []byte) *TypedBucket

func (*TypedBucket) GetFloat64

func (bucket *TypedBucket) GetFloat64(name string) *float64

func (*TypedBucket) GetInt32

func (bucket *TypedBucket) GetInt32(name string) *int32

func (*TypedBucket) GetInt32WithDefault

func (bucket *TypedBucket) GetInt32WithDefault(name string, defaultValue int32) int32

func (*TypedBucket) GetInt64

func (bucket *TypedBucket) GetInt64(name string) *int64

func (*TypedBucket) GetInt64WithDefault

func (bucket *TypedBucket) GetInt64WithDefault(name string, defaultValue int64) int64

func (*TypedBucket) GetLinkCount

func (bucket *TypedBucket) GetLinkCount(fieldType FieldType, value []byte) *int32

func (*TypedBucket) GetList

func (bucket *TypedBucket) GetList(name string) []interface{}

func (*TypedBucket) GetMap

func (bucket *TypedBucket) GetMap(name string) map[string]interface{}

func (*TypedBucket) GetOrCreateBucket

func (bucket *TypedBucket) GetOrCreateBucket(name string) *TypedBucket

func (*TypedBucket) GetOrCreatePath

func (bucket *TypedBucket) GetOrCreatePath(path ...string) *TypedBucket

func (*TypedBucket) GetParent

func (bucket *TypedBucket) GetParent() *TypedBucket

func (*TypedBucket) GetPath

func (bucket *TypedBucket) GetPath(path ...string) *TypedBucket

func (*TypedBucket) GetString

func (bucket *TypedBucket) GetString(name string) *string

func (*TypedBucket) GetStringList

func (bucket *TypedBucket) GetStringList(name string) []string

func (*TypedBucket) GetStringOrError

func (bucket *TypedBucket) GetStringOrError(name string) string

func (*TypedBucket) GetStringWithDefault

func (bucket *TypedBucket) GetStringWithDefault(name string, defaultValue string) string

func (*TypedBucket) GetTime

func (bucket *TypedBucket) GetTime(name string) *time.Time

func (*TypedBucket) GetTimeOrError

func (bucket *TypedBucket) GetTimeOrError(name string) time.Time

func (*TypedBucket) IncrementLinkCount

func (bucket *TypedBucket) IncrementLinkCount(fieldType FieldType, value []byte) (int, error)

func (*TypedBucket) IsKeyPresent

func (bucket *TypedBucket) IsKeyPresent(key []byte) bool

func (*TypedBucket) IsStringListEmpty

func (bucket *TypedBucket) IsStringListEmpty(name string) bool

func (*TypedBucket) IterateStringList

func (bucket *TypedBucket) IterateStringList() ast.SeekableSetCursor

func (*TypedBucket) IterateStringListInDirection added in v0.1.46

func (bucket *TypedBucket) IterateStringListInDirection(forward bool) ast.SeekableSetCursor

func (*TypedBucket) OpenCursor

func (bucket *TypedBucket) OpenCursor(_ *bbolt.Tx, forward bool) ast.SetCursor

func (*TypedBucket) OpenSeekableCursor

func (bucket *TypedBucket) OpenSeekableCursor() ast.SeekableSetCursor

func (*TypedBucket) OpenTypedCursor

func (bucket *TypedBucket) OpenTypedCursor(_ *bbolt.Tx, forward bool) ast.SetCursor

func (*TypedBucket) ProceedWithSet

func (bucket *TypedBucket) ProceedWithSet(name string, checker FieldChecker) bool

func (*TypedBucket) PutList

func (bucket *TypedBucket) PutList(name string, value []interface{}, checker FieldChecker) *TypedBucket

func (*TypedBucket) PutMap

func (bucket *TypedBucket) PutMap(name string, value map[string]interface{}, checker FieldChecker, allowNested bool) *TypedBucket

func (*TypedBucket) PutValue

func (bucket *TypedBucket) PutValue(key []byte, value []byte) *TypedBucket

func (*TypedBucket) ReadStringList

func (bucket *TypedBucket) ReadStringList() []string

func (*TypedBucket) SetBool

func (bucket *TypedBucket) SetBool(name string, value bool, checker FieldChecker) *TypedBucket

func (*TypedBucket) SetFloat64

func (bucket *TypedBucket) SetFloat64(name string, value float64, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetInt32

func (bucket *TypedBucket) SetInt32(name string, value int32, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetInt64

func (bucket *TypedBucket) SetInt64(name string, value int64, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetLinkCount

func (bucket *TypedBucket) SetLinkCount(fieldType FieldType, value []byte, count int) (*int32, error)

func (*TypedBucket) SetListEntry

func (bucket *TypedBucket) SetListEntry(fieldType FieldType, value []byte) *TypedBucket

func (*TypedBucket) SetNil

func (bucket *TypedBucket) SetNil(name string)

func (*TypedBucket) SetString

func (bucket *TypedBucket) SetString(name string, value string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetStringList

func (bucket *TypedBucket) SetStringList(name string, value []string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetStringP

func (bucket *TypedBucket) SetStringP(name string, value *string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetTime

func (bucket *TypedBucket) SetTime(name string, value time.Time, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetTimeP

func (bucket *TypedBucket) SetTimeP(name string, value *time.Time, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) Tx

func (bucket *TypedBucket) Tx() *bbolt.Tx

type TypedForwardBoltCursor

type TypedForwardBoltCursor struct {
	BaseBoltCursor
	// contains filtered or unexported fields
}

func (*TypedForwardBoltCursor) Next

func (f *TypedForwardBoltCursor) Next()

func (*TypedForwardBoltCursor) Seek

func (f *TypedForwardBoltCursor) Seek(val []byte)

type TypedReverseBoltCursor

type TypedReverseBoltCursor struct {
	BaseBoltCursor
	// contains filtered or unexported fields
}

func (*TypedReverseBoltCursor) Next

func (f *TypedReverseBoltCursor) Next()

func (*TypedReverseBoltCursor) Seek

func (f *TypedReverseBoltCursor) Seek(val []byte)

type UniqueIndexDuplicateError

type UniqueIndexDuplicateError struct {
	Field      string
	Value      string
	EntityType string
}

UniqueIndexDuplicateError is an error that is returned when a unique index is violated due to duplicate values

func (*UniqueIndexDuplicateError) Error

func (err *UniqueIndexDuplicateError) Error() string

type UntypedEntityChangeState added in v0.2.0

type UntypedEntityChangeState interface {
	GetEventId() string
	GetEntityId() string
	GetCtx() MutateContext
	GetChangeType() EntityEventType
	GetInitialState() Entity
	GetFinalState() Entity
	GetInitialParentEntity() Entity
	GetFinalParentEntity() Entity
	GetStore() Store
	IsParentEvent() bool
}

UntypedEntityChangeState instances are passed to entity event listeners that don't need the concrete entity types

type UntypedEntityConstraint added in v0.2.0

type UntypedEntityConstraint interface {
	ProcessPreCommit(state UntypedEntityChangeState) error
	ProcessPostCommit(state UntypedEntityChangeState)
}

UntypedEntityConstraint instances can react to entity changes in cases where you don't care about the entity type or need to react to changes of multiple entity types

type ValidIdsCursors

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

func (*ValidIdsCursors) Current

func (cursor *ValidIdsCursors) Current() []byte

func (*ValidIdsCursors) IsExtendedDataPresent

func (cursor *ValidIdsCursors) IsExtendedDataPresent() bool

func (*ValidIdsCursors) IsValid

func (cursor *ValidIdsCursors) IsValid() bool

func (*ValidIdsCursors) Next

func (cursor *ValidIdsCursors) Next()

func (*ValidIdsCursors) Seek

func (cursor *ValidIdsCursors) Seek(bytes []byte)

Jump to

Keyboard shortcuts

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