storeql

package module
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: GPL-3.0 Imports: 9 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoId = errors.New("storable entity given has no id")

Functions

func DeleteFromDB

func DeleteFromDB(ctx context.Context, db *sqlx.DB, storables ...Storable) error

func ExecBoilerplate added in v1.5.6

func ExecBoilerplate(action string, storable Storable) (boilerplate string)

func InsertIntoDB

func InsertIntoDB(ctx context.Context, db *sqlx.DB, storables ...Storable) error

InsertIntoDB inserts the storable entity to the DB Finally, it assigns the inserted Id to the given entities

func SQLColumns

func SQLColumns(s Storable) (cols []string)

func SQLValues added in v1.4.0

func SQLValues(s Storable) (vals []driver.Value)

func UpdateIntoDB

func UpdateIntoDB(ctx context.Context, db *sqlx.DB, storables ...Storable) error

func UpsertIntoDB

func UpsertIntoDB(ctx context.Context, db *sqlx.DB, storables ...Storable) error

func Where added in v1.5.1

func Where(ctx context.Context, db *sqlx.DB, storable Storable, whereClause string, args ...interface{}) *sqlx.Row

func WhereMany added in v1.5.1

func WhereMany(ctx context.Context, db *sqlx.DB, storable Storable, whereClause string, args ...interface{}) (*sqlx.Rows, error)

Types

type PqErr added in v1.1.0

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

func (*PqErr) Error added in v1.1.0

func (err *PqErr) Error() string

func (*PqErr) Is added in v1.1.0

func (err *PqErr) Is(errChecker func(error) *pq.Error) bool

type Storable

type Storable interface {
	GetId() uint64
	SetId(uint64)
	SQLTable() string
	SQLMap() map[string]driver.Value
}

Storable entity is any entity that can be stored in an SQL database

Directories

Path Synopsis
Package name contains the naming conventions of storeql
Package name contains the naming conventions of storeql
test
sqlhelp
Package sqlhelp contains testing helpers for sql transactions.
Package sqlhelp contains testing helpers for sql transactions.

Jump to

Keyboard shortcuts

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