sess

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BaseIdentifierUnsetError = errors.New(
	"The base provided has an identifier but it hasn't been set.",
)
View Source
var BaseNoIdentifierError = errors.New(
	"The base provided has no understandable identifier.",
)
View Source
var StopOnFailure = func() ([]actionOption, []base.Base) {
	return []actionOption{
		func(ops *actionOptions) {
			ops.stopOnFailure = true
		},
	}, nil
}

Functions

func DeleteObject

func DeleteObject(object base.Base) error

DeleteObject deletes the object provided from the DB using a new session from the global connection pool.

func DeleteObjects

func DeleteObjects(args ...ObjectsOrOptions) []error

DeleteObjects deletes the objects provided from the DB using a new session from the global connection pool.

func GetObject

func GetObject(object base.Base, idValue interface{}) error

GetObject gets the object with the provided id from the DB using a new session from the global connection pool.

func ObjectChanged

func ObjectChanged(object base.Base) bool

func Query

func Query(objects ...base.Base) *query.Query

func SaveObject

func SaveObject(object base.Base) error

SaveObject saves the given object to the DB new session from the global connection pool.

func SaveObjects

func SaveObjects(args ...ObjectsOrOptions) []error

SaveObjects saves the provided objects to the DB using a new session from the global connection pool.

func Saved

func Saved(object base.Base) bool

func Transactionized

func Transactionized(
	fn func(*sqlx.Tx) error,
) (err error)

func UpdateObject

func UpdateObject(object base.Base) error

UpdateObject updates the object provided in the DB using a new session from the global connection pool.

Types

type ColumnFilter

type ColumnFilter func(string, *sql.NamedArg) bool

type IdentifierSet added in v0.2.3

type IdentifierSet map[string]interface{}

type ObjectsOrOptions added in v0.1.2

type ObjectsOrOptions func() ([]actionOption, []base.Base)

func Objs added in v0.1.2

func Objs(objs ...base.Base) ObjectsOrOptions

type QueryParts

type QueryParts struct {
	Bindvars,
	ColumnNames []string
	VariableValueMap map[string]interface{}
}

func QueryPartsFromObject

func QueryPartsFromObject(
	object base.Base, filters ...ColumnFilter,
) QueryParts

func (*QueryParts) AddColumnName

func (self *QueryParts) AddColumnName(columnNames ...string)

func (*QueryParts) AddValue

func (self *QueryParts) AddValue(values ...sql.NamedArg)

func (QueryParts) AsInsert

func (self QueryParts) AsInsert() string

func (QueryParts) AsUpdate

func (self QueryParts) AsUpdate() string

type Session

type Session struct {
	Pool *pool.ConnectionPool
}

Session is a helper wrapper for a connection pool that has common helper functions.

func NewSession

func NewSession() (*Session, error)

func NewSessionFromGlobal

func NewSessionFromGlobal() (*Session, error)

func NewSessionFromPool

func NewSessionFromPool(connPool *pool.ConnectionPool) *Session

func (Session) DeleteObject

func (self Session) DeleteObject(object base.Base) error

DeleteObject deletes the object provided from the DB.

func (Session) DeleteObjects

func (self Session) DeleteObjects(args ...ObjectsOrOptions) []error

DeleteObjects deletes the objects provided from the DB.

func (Session) GetObject

func (self Session) GetObject(object base.Base, idValue interface{}) error

GetObject gets the object with the provided id from the DB.

func (Session) Query

func (self Session) Query(objects ...base.Base) *query.Query

func (Session) SaveObject

func (self Session) SaveObject(object base.Base) error

SaveObject saves the given object to the DB.

func (Session) SaveObjects

func (self Session) SaveObjects(args ...ObjectsOrOptions) []error

SaveObjects saves the provided objects to the DB.

func (Session) Transactionized

func (self Session) Transactionized(
	fn func(*sqlx.Tx) error,
) (err error)

func (Session) UpdateObject

func (self Session) UpdateObject(object base.Base) error

UpdateObject updates the object provided in the DB.

Jump to

Keyboard shortcuts

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