tgw

package module
v0.0.0-...-dd656c8 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

Go Table-Gateway

Simple wrapper to handle CRUD database operations by utilizing jmoiron/sqlx.

Usage

TODO: ...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStructConfig = errors.New("invalid or incomplete tags for given struct")
	ErrNoPrimary    = errors.New("no primary key found")
	ErrMultiPrimary = errors.New("multiple primary keys not yet supported")
)

Errors...

Functions

This section is empty.

Types

type Gateway

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

Gateway is the main struct

func NewGateway

func NewGateway(dbconn *sqlx.DB, table string) (*Gateway, error)

NewGateway returns a new instance of Gateway

func (*Gateway) Create

func (g *Gateway) Create(dest interface{}) error

Create writes entity to database

func (*Gateway) Delete

func (g *Gateway) Delete(dest interface{}) error

Delete removes entity with given ID from database

func (*Gateway) Read

func (g *Gateway) Read(dest interface{}) error

Read returns entity with given ID from database

func (*Gateway) Select

func (g *Gateway) Select(dest interface{}, params Selectors, orderby OrderBy) error

Select is a simple select interface using a map as query parameters.

func (*Gateway) Update

func (g *Gateway) Update(dest interface{}) error

Update updates entity in database

type OrderBy

type OrderBy map[string]string

OrderBy holds ordering informations for queries

type Selectors

type Selectors map[string]interface{}

Selectors holds query parameters for simple selects

Jump to

Keyboard shortcuts

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