db

package
v0.0.0-...-43defc9 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDB *db

	// Prefix for lookup in registry
	DBServiceNamespace = "go.micro.db"

	// Used to lookup the metadata for the driver
	DBDriverKey = "driver"

	// supported drivers: mysql, elastic, cassandra
	Drivers = map[string]Driver{}

	// Errors
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
	ErrNotAvailable  = errors.New("not available")
)

Functions

func Create

func Create(db *mdb.Database, r *mdb.Record) error

func Delete

func Delete(db *mdb.Database, id string) error

func Init

func Init(s selector.Selector) error

func Read

func Read(db *mdb.Database, id string) (*mdb.Record, error)
func Search(db *mdb.Database, md map[string]string, limit, offset int64) ([]*mdb.Record, error)

func Update

func Update(db *mdb.Database, r *mdb.Record) error

Types

type DB

type DB interface {
	// Initialise the database
	// If the database doesn't exist
	// will throw an error
	Init(mdb *mdb.Database) error
	// Close the connection
	Close() error
	// Query commands
	Read(id string) (*mdb.Record, error)
	Create(mdb *mdb.Record) error
	Update(mdb *mdb.Record) error
	Delete(id string) error
	Search(md map[string]string, limit, offset int64) ([]*mdb.Record, error)
}

An initialised DB connection Must call Init to load Database/Table

type Driver

type Driver interface {
	NewDB(nodes ...*registry.Node) (DB, error)
}

Database Driver

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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