reader

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drivers

func Drivers() []string

Drivers returns a sorted list of the names of the registered drivers.

func Register

func Register(name string, driver Driver)

Register makes a database driver available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type ConnOpts

type ConnOpts struct {
	DSN             string
	Timeout         time.Duration
	MaxConnLifetime time.Duration
	MaxConns        int
	MaxIdleConns    int
}

ConnOpts are the options to create a connection

type Driver

type Driver interface {
	IsSupported(string) bool
	NewConnection(ConnOpts) (Reader, error)
}

Driver is a driver interface used to support multiple drivers

type ReadTableOpt

type ReadTableOpt struct {
	// PrimaryKey is the primary key
	PrimaryKey string
	// Columns contains the (quoted) column of the table
	Columns []string
	// Match is a condition field to dump only certain amount data
	Match string
	// Sort the results
	Sorts map[string]string
	// Defines a limit of results to be fetched
	Limit uint64
	// Relationships defines an slice of relationship definitions
	Relationships []*RelationshipOpt
}

ReadTableOpt represents the read table options

type Reader

type Reader interface {
	// GetStructure returns the SQL used to create the database tables
	GetStructure() (string, error)
	// GetTables returns a list of all databases tables
	GetTables() ([]string, error)
	// GetColumns return a list of all columns for a given table
	GetColumns(string) ([]string, error)
	// FormatColumn returns a escaped table.column string
	FormatColumn(tableName string, columnName string) string
	// ReadTable returns a channel with all database rows
	ReadTable(string, chan<- database.Row, ReadTableOpt) error
	// Close closes the reader resources and releases them.
	Close() error
}

Reader provides an interface to access database stores.

func Connect

func Connect(opts ConnOpts) (reader Reader, err error)

Connect acts as fectory method that returns a reader from a DSN

type RelationshipOpt

type RelationshipOpt struct {
	Table           string
	ForeignKey      string
	ReferencedTable string
	ReferencedKey   string
}

RelationshipOpt represents the relationships options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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