go-platform: github.com/micro/go-platform/db Index | Files | Directories

package db

import "github.com/micro/go-platform/db"

Package db is an interface for abstracting away CRUD.

Index

Package Files

context.go db.go options.go os.go record.go

Variables

var (
    DefaultDatabase = "micro"
    DefaultTable    = "micro"
)

func NewContext Uses

func NewContext(ctx context.Context, c DB) context.Context

type DB Uses

type DB interface {
    Close() error
    Init(...Option) error
    Options() Options
    Read(id string) (Record, error)
    Create(r Record) error
    Update(r Record) error
    Delete(id string) error
    Search(...SearchOption) ([]Record, error)
    String() string
}

func FromContext Uses

func FromContext(ctx context.Context) (DB, bool)

func NewDB Uses

func NewDB(opts ...Option) DB

type Metadata Uses

type Metadata map[string]interface{}

type Option Uses

type Option func(*Options)

func Client Uses

func Client(c client.Client) Option

func Database Uses

func Database(d string) Option

func Table Uses

func Table(t string) Option

type Options Uses

type Options struct {
    Database string
    Table    string

    Client client.Client

    // For alternative options
    Context context.Context
}

type Record Uses

type Record interface {
    Id() string
    Created() int64
    Updated() int64
    Metadata() Metadata
    Bytes() []byte
    Scan(v interface{}) error
}

func NewRecord Uses

func NewRecord(id string, md Metadata, data interface{}) Record

type SearchOption Uses

type SearchOption func(*SearchOptions)

func WithLimit Uses

func WithLimit(l int64) SearchOption

func WithMetadata Uses

func WithMetadata(md Metadata) SearchOption

func WithOffset Uses

func WithOffset(ot int64) SearchOption

type SearchOptions Uses

type SearchOptions struct {
    Metadata Metadata
    Limit    int64
    Offset   int64
}

Directories

PathSynopsis
protoPackage go_micro_os_db is a generated protocol buffer package.

Package db imports 6 packages (graph) and is imported by 2 packages. Updated 2018-06-22. Refresh now. Tools for package owners.