database

package
v0.0.0-...-ee126ca Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T Model](db *Database, key string) (T, error)

Get is the generic equivalent of Database.Get.

func Values

func Values[T Model](db *Database, prefixes ...string) ([]T, error)

Values is the generic equivalent of Database.Values.

Types

type Database

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

func New

func New() (*Database, error)

func (*Database) Close

func (db *Database) Close() error

func (*Database) Get

func (db *Database) Get(key string, val Model) error

Get retrieves a model from the database. If the model is not found, a bader.ErrKeyNotFound error is returned.

func (*Database) Put

func (db *Database) Put(models ...Model) error

Put one ore more models into the database.

func (*Database) RawGet

func (db *Database) RawGet(collection, key string) ([]byte, error)

RawGet return the raw value of a key in JSON format.

func (*Database) RawValues

func (db *Database) RawValues(w io.Writer, prefixes ...string) error

RawValues writes the raw database values of the prefixes to the provided writer.

func (*Database) Values

func (db *Database) Values(forModel Model, prefixes ...string) ([]Model, error)

Values returns an list of models with the same type as the forModel parameter.

type Entry

type Entry struct {
	Key   string
	Value []byte
}

type Model

type Model interface {
	Collection() string
	Key() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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