Documentation ¶
Index ¶
- func Close() error
- func Initialize(path string) error
- func ReplaceDefaultRepositoryWith(repo Repository) func()
- type BoltRepository
- func (repo BoltRepository) Close() error
- func (repo BoltRepository) Delete(bucketName string, model Model) error
- func (repo BoltRepository) Fetch(bucketName string, name string, model Model) (bool, error)
- func (repo BoltRepository) FetchAll(bucketName string, modelFn func([]byte) (Model, error)) (interface{}, error)
- func (repo BoltRepository) Save(bucketName string, model Model) error
- type EntryNotFound
- type Model
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReplaceDefaultRepositoryWith ¶
func ReplaceDefaultRepositoryWith(repo Repository) func()
ReplaceDefaultRepositoryWith replace the default repository
Types ¶
type BoltRepository ¶
type BoltRepository struct {
// contains filtered or unexported fields
}
BoltRepository represents a bbolt database
func (BoltRepository) Close ¶
func (repo BoltRepository) Close() error
Close closes bbolt db connection
func (BoltRepository) Delete ¶
func (repo BoltRepository) Delete(bucketName string, model Model) error
Delete deletes the model from bucketName
func (BoltRepository) Fetch ¶
Fetch retrieves the model identified by name from the bucket named bucketName
type Repository ¶
type Repository interface { Save(bucketName string, model Model) error Delete(bucketName string, model Model) error Fetch(bucketName string, name string, model Model) (bool, error) FetchAll(bucketName string, modelFn func(data []byte) (Model, error)) (interface{}, error) Close() error }
Repository holds the necessary method to persist and retrieve data from database
func DefaultRepository ¶
func DefaultRepository() Repository
DefaultRepository returns the global repository
func NewBoltRepository ¶
func NewBoltRepository(path string) (Repository, error)
NewBoltRepository returns the repository and error if any
Click to show internal directories.
Click to hide internal directories.