storage

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base added in v0.5.1

type Base struct {
	ID        string    `json:"id"`
	Active    bool      `json:"active"`
	Canceled  bool      `json:"canceled"`
	CreatedAt time.Time `json:"created"`
	UpdatedAt time.Time `json:"updated"`
}

func New added in v0.5.1

func New(opts ...Option) *Base

func (*Base) Delete added in v0.5.1

func (tx *Base) Delete(s Storable, db *DB) error

func (*Base) Get added in v0.5.1

func (tx *Base) Get(s Storable, db *DB) (Storable, error)

func (*Base) Inactivate added in v0.5.1

func (tx *Base) Inactivate(s Storable, db *DB) error

func (Base) Key added in v0.5.1

func (tx Base) Key() string

func (*Base) Set added in v0.5.1

func (tx *Base) Set(s Storable, db *DB) error

type DB

type DB struct {
	*buntdb.DB
}

func NewBunt

func NewBunt(filePath string) *DB

func (*DB) Delete

func (db *DB) Delete(index string, object Storable) error

Delete a storable item.

func (*DB) Exists

func (db *DB) Exists(storable Storable) (ok bool, err error)

Exists checks is storable item exists

func (*DB) Get

func (db *DB) Get(object Storable) error

Get a storable item

func (*DB) Set

func (db *DB) Set(object Storable) error

Set a storable item.

type Option added in v0.5.1

type Option func(b *Base)

func ID added in v0.5.1

func ID(id string) Option

type Storable

type Storable interface {
	Key() string
}

Storable items must provide a function to retrieve the database key

Jump to

Keyboard shortcuts

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