Documentation ¶
Index ¶
- Constants
- func AppendFn[T any](collection *[]T) func(obj interface{}) (interface{}, error)
- func FilterFn[T any](collection *[]T, predicate func(T) bool) func(obj interface{}) (interface{}, error)
- func FirstFn[T any](element *T, predicate func(T) bool) func(obj interface{}) (interface{}, error)
- func IsErrObjectNotFound(e error) bool
- type Database
- func (d *Database) Close() error
- func (d *Database) ConvertToKey(v int) []byte
- func (d *Database) CreateObject(bucketName string, objFn func(uint64) (int, interface{})) error
- func (d *Database) CreateObjectWithId(bucketName string, id int, obj interface{}) error
- func (d *Database) CreateObjectWithStringId(bucketName string, id []byte, obj interface{}) error
- func (d *Database) DatabaseFileName() string
- func (d *Database) DeleteAllObjects(bucketName string, obj interface{}, ...) error
- func (d *Database) DeleteObject(bucketName string, key []byte) error
- func (d *Database) GetAll(bucketName string, obj interface{}, ...) error
- func (d *Database) GetAllWithKeyPrefix(bucketName string, keyPrefix []byte, obj interface{}, ...) error
- func (d *Database) GetObject(bucketName string, key []byte, object interface{}) error
- func (d *Database) MarshalObject(object interface{}) ([]byte, error)
- func (d *Database) Migrate() error
- func (d *Database) SetServiceName(bucketName string) error
- func (d *Database) UnmarshalObject(data []byte, object interface{}) error
- func (d *Database) UpdateObject(bucketName string, key []byte, object interface{}) error
- type Options
Constants ¶
const ( DatabaseFileName = "reporter.db" EncryptedDatabaseFileName = "reporter.edb" )
const (
SettingsBucket bucket = iota
)
Variables ¶
This section is empty.
Functions ¶
func FilterFn ¶
func FilterFn[T any](collection *[]T, predicate func(T) bool) func(obj interface{}) (interface{}, error)
FilterFn appends elements to the given collection when the predicate is true
func FirstFn ¶
FirstFn sets the element to the first one that satisfies the predicate and stops the computation, returns ErrStop on success
func IsErrObjectNotFound ¶
Types ¶
type Database ¶
func (*Database) ConvertToKey ¶
ConvertToKey returns an 8-byte big endian representation of v. This function is typically used for encoding integer IDs to byte slices so that they can be used as BoltDB keys.
func (*Database) CreateObject ¶
CreateObject creates a new object in the bucket, using the next bucket sequence id
func (*Database) CreateObjectWithId ¶
CreateObjectWithId creates a new object in the bucket, using the specified id
func (*Database) CreateObjectWithStringId ¶
CreateObjectWithStringId creates a new object in the bucket, using the specified id
func (*Database) DatabaseFileName ¶
DatabaseFileName get the database filename
func (*Database) DeleteAllObjects ¶
func (d *Database) DeleteAllObjects(bucketName string, obj interface{}, matchingFn func(o interface{}) (id int, ok bool)) error
DeleteAllObjects delete all objects where matching() returns (id, ok). TODO: think about how to return the error inside (maybe change ok to type err, and use "notfound"?
func (*Database) DeleteObject ¶
DeleteObject is a generic function used to delete an object inside a database.
func (*Database) GetAllWithKeyPrefix ¶
func (*Database) GetObject ¶
GetObject is a generic function used to retrieve an unmarshalled object from a database.
func (*Database) MarshalObject ¶
MarshalObject encodes an object to binary format
func (*Database) SetServiceName ¶
SetServiceName is a generic function used to create a bucket inside a database.
func (*Database) UnmarshalObject ¶
UnmarshalObject decodes an object from binary data using the jsoniter library. It is mainly used to accelerate environment(endpoint) decoding at the moment.