Documentation
¶
Index ¶
- func WithSequenceAsIdFunc[I constraints.Integer, T any](seq *badger.Sequence) func(_ *T) (I, error)
- type Doc
- type Instance
- func (s *Instance[I, T, PT]) Delete(id I) error
- func (s *Instance[I, T, PT]) Get(id I) (*T, error)
- func (s *Instance[I, T, PT]) NewIterator(opts badger.IteratorOptions) *Iterator[I, T]
- func (s *Instance[I, T, PT]) Query(q string) (badgerutils.Iterator[I, *T], error)
- func (s *Instance[I, T, PT]) Set(v *T, opts ...any) error
- type Iterator
- func (it *Iterator[I, T]) Close()
- func (it *Iterator[I, T]) Item() *badger.Item
- func (it *Iterator[I, T]) Key() (k I, err error)
- func (it *Iterator[I, T]) Next()
- func (it *Iterator[I, T]) Rewind()
- func (it *Iterator[I, T]) Seek(key []byte)
- func (it *Iterator[I, T]) SeekT(key I)
- func (it *Iterator[I, T]) Valid() bool
- func (it *Iterator[I, T]) Value() (*T, error)
- type Object
- type Record
- type Store
- func (s *Store[I, T, PT]) IdCodec() codec.Codec[I]
- func (s *Store[I, T, PT]) Indexer(name string) *indexing.Extension[I, T]
- func (s *Store[I, T, PT]) Instantiate(txn *badger.Txn) *Instance[I, T, PT]
- func (s *Store[I, T, PT]) Prefix() []byte
- func (s *Store[I, T, PT]) WithExtension(name string, ext extstore.Extension[I, T]) *Store[I, T, PT]
- func (s *Store[I, T, PT]) WithExtractor(e schema.PathExtractor[*T]) *Store[I, T, PT]
- func (s *Store[I, T, PT]) WithFlatExtractor(e schema.PathExtractor[[]byte]) *Store[I, T, PT]
- func (s *Store[I, T, PT]) WithIdCodec(c codec.Codec[I]) *Store[I, T, PT]
- func (s *Store[I, T, PT]) WithIdFunc(f func(*T) (I, error)) *Store[I, T, PT]
- func (s *Store[I, T, PT]) WithIndexer(name string, idx indexing.Indexer[T]) *Store[I, T, PT]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithSequenceAsIdFunc ¶
func WithSequenceAsIdFunc[ I constraints.Integer, T any, ]( seq *badger.Sequence, ) func(_ *T) (I, error)
WithSequenceAsIdFunc is an option to set the id function to use a sequence.
Types ¶
type Doc ¶
type Doc[I comparable] map[string]any
Doc is a Record type that is schemaless. This type is serialized entirely in msgpack format so MsgpackPathExtractor can be used as flat extractor in record store to speed up queries without the need of deserializing the whole document.
func (Doc[I]) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Doc[I]) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Instance ¶
type Instance[ I comparable, T any, PT Record[I, T], ] struct { // contains filtered or unexported fields }
Instance is an instance of the Store.
func (*Instance[I, T, PT]) NewIterator ¶
func (s *Instance[I, T, PT]) NewIterator(opts badger.IteratorOptions) *Iterator[I, T]
NewIterator implements the badgerutils.StoreInstance interface.
type Iterator ¶
type Iterator[I comparable, T any] struct { // contains filtered or unexported fields }
Iterator is an iterator that unmarshal id, data and optionally fetch metadata.
type Object ¶
type Object[I comparable, D any] struct { Id I `json:"id,omitempty"` Data D `json:"data,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
Object is a generic object that can be stored in as a Record.
func NewObject ¶
func NewObject[I comparable, D any](data D) *Object[I, D]
NewObject creates a new object with the given data.
func NewObjectWithId ¶
func NewObjectWithId[I comparable, D any](id I, data D) *Object[I, D]
NewObjectWithId creates a new object with the given data and id.
func (Object[I, D]) GetId ¶
func (obj Object[I, D]) GetId() I
GetId implements the Record interface.
func (Object[I, D]) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (*Object[I, D]) SetId ¶
func (obj *Object[I, D]) SetId(id I)
SetId implements the Record interface.
func (*Object[I, D]) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
type Record ¶
type Record[I comparable, T any] interface { *T GetId() I SetId(I) encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Record is a model for something that is serializable and has an unique id assigned to it. One thing to consider here is that the id is serialized as key in the store so there's no need to serialize it as part of the value.
type Store ¶
type Store[ I comparable, T any, PT Record[I, T], ] struct { // contains filtered or unexported fields }
Store is a generic store for entities.
func New ¶
func New[ I comparable, T any, PT Record[I, T], ]( base badgerutils.Instantiator[badgerutils.BadgerStore], ) *Store[I, T, PT]
New creates a new Store.
func (*Store[I, T, PT]) Instantiate ¶
Instantiate implements the badgerutils.Instantiator interface.
func (*Store[I, T, PT]) WithExtension ¶
WithExtension adds an extension to the store.
func (*Store[I, T, PT]) WithExtractor ¶
func (s *Store[I, T, PT]) WithExtractor(e schema.PathExtractor[*T]) *Store[I, T, PT]
WithExtractor is an option to set the extractor.
func (*Store[I, T, PT]) WithFlatExtractor ¶
func (s *Store[I, T, PT]) WithFlatExtractor(e schema.PathExtractor[[]byte]) *Store[I, T, PT]
WithFlatExtractor is an option to set the flat extractor.
func (*Store[I, T, PT]) WithIdCodec ¶
WithIdCodec is an option to set the id codec.
func (*Store[I, T, PT]) WithIdFunc ¶
WithIdFunc is an option to set the id function.