store

package
Version: v0.0.0-...-6bf1803 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error is of type notFound

func NewNotFoundError

func NewNotFoundError(tableName string, key string, value interface{}) error

NewNotFoundError return a not found error for the given input

Types

type Named

type Named interface {
	GetName() string
}

Named represents a named object

type NotFound

type NotFound struct {
	Msg string
}

NotFound is a custom error that is returned when no item can be found

func (NotFound) Error

func (u NotFound) Error() string

type Schema

type Schema interface {
	AddToSchema(table Table)
	// contains filtered or unexported methods
}

Schema represents the db schema

func NewSchema

func NewSchema() Schema

NewSchema start a new DB schema

type Store

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

Store is used to connect to the database

func New

func New(schema Schema) (*Store, error)

New createa a new Store with the given schema

func (*Store) Read

func (s *Store) Read(table string, key string, value interface{}) (interface{}, error)

Read returns a row from a DB table

func (*Store) Remove

func (s *Store) Remove(table string, key string, value interface{}) error

Remove removes a row from the DB table

func (*Store) Write

func (s *Store) Write(table string, objs ...interface{}) error

Write inserts a row into the table

func (*Store) WriteAndBlock

func (s *Store) WriteAndBlock(table string, objs ...interface{}) (Transaction, error)

WriteAndBlock writes to the store but block any other writing until the returned function is called

type Table

type Table interface {
	Named
	GetTableSchema() *memdb.TableSchema
}

Table represents the name and schema of a DB

type Transaction

type Transaction interface {
	Commit()
	Abort()
	Insert(table string, value interface{}) error
}

Transaction represents the open DB transaction

Source Files

Jump to

Keyboard shortcuts

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