sql

package
v0.0.0-...-789275d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Port     int
	Addr     string
	User     string
	Driver   string
	Password string
	Database string
	Log      sink.Sink
}

Conn defines a struct which will generate a new sqlx connection for making sql queries.

func (Conn) New

func (s Conn) New() (*sqlx.DB, error)

New returns a new instance of a sqlx.DB connected to the db with the provided credentials pulled from the host environment.

type DB

type DB interface {
	New() (*sqlx.DB, error)
}

DB defines an interface which exposes a method to return a new underline sql.Database.

type SQL

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

SQL defines an struct which implements the db.Provider which allows us execute CRUD ops.

func New

func New(s sink.Sink, d DB, ts ...tables.TableMigration) *SQL

New returns a new instance of SQL.

func (*SQL) Count

func (sq *SQL) Count(table db.TableIdentity) (int, error)

Count retrieves the total number of records from the specific table from the db.

func (*SQL) Delete

func (sq *SQL) Delete(table db.TableIdentity, index string, indexValue interface{}) error

Delete removes the giving data from the specific db with the specific index and value.

func (*SQL) Get

func (sq *SQL) Get(table db.TableIdentity, consumer db.TableConsumer, index string, indexValue interface{}) error

Get retrieves the giving data from the specific db with the specific index and value.

func (*SQL) GetAll

func (sq *SQL) GetAll(table db.TableIdentity, order string, orderBy string) ([]map[string]interface{}, error)

GetAll retrieves the giving data from the specific db with the specific index and value.

func (*SQL) GetAllPerPage

func (sq *SQL) GetAllPerPage(table db.TableIdentity, order string, orderBy string, page int, responsePerPage int) ([]map[string]interface{}, int, error)

GetAllPerPage retrieves the giving data from the specific db with the specific index and value.

func (*SQL) Save

func (sq *SQL) Save(identity db.TableIdentity, table db.TableFields) error

Save takes the giving table name with the giving fields and attempts to save this giving data appropriately into the giving db.

func (*SQL) Update

func (sq *SQL) Update(identity db.TableIdentity, table db.TableFields, index string) error

Update takes the giving table name with the giving fields and attempts to update this giving data appropriately into the giving db. index - defines the string which should identify the key to be retrieved from the fields to target the data to be updated in the db.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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