Documentation ¶
Index ¶
- type Connection
- type Execer
- func (ex *Execer) Exec() (*dat.Result, error)
- func (ex *Execer) QueryJSON() ([]byte, error)
- func (ex *Execer) QueryObject(dest interface{}) error
- func (ex *Execer) QueryScalar(destinations ...interface{}) error
- func (ex *Execer) QuerySlice(dest interface{}) error
- func (ex *Execer) QueryStruct(dest interface{}) error
- func (ex *Execer) QueryStructs(dest interface{}) error
- func (ex *Execer) Queryx() (*sqlx.Rows, error)
- type IQueryable
- type Queryable
- func (q *Queryable) DeleteFrom(table string) *dat.DeleteBuilder
- func (q *Queryable) Exec(cmd string, args ...interface{}) (*dat.Result, error)
- func (q *Queryable) ExecBuilder(b dat.Builder) error
- func (q *Queryable) ExecMulti(commands ...*dat.Expression) (int, error)
- func (q *Queryable) Insect(table string) *dat.InsectBuilder
- func (q *Queryable) InsertInto(table string) *dat.InsertBuilder
- func (q *Queryable) SQL(sql string, args ...interface{}) *dat.RawBuilder
- func (q *Queryable) Select(columns ...string) *dat.SelectBuilder
- func (q *Queryable) SelectDoc(columns ...string) *dat.SelectDocBuilder
- func (q *Queryable) Update(table string) *dat.UpdateBuilder
- func (q *Queryable) Upsert(table string) *dat.UpsertBuilder
- type Session
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection is a connection to the database with an EventReceiver
func NewConnection ¶
func NewConnection(db *sql.DB, driverName string) *Connection
NewConnection instantiates a Connection for a given database/sql connection
func NewConnectionFromSqlx ¶
func NewConnectionFromSqlx(dbx *sqlx.DB) *Connection
NewConnectionFromSqlx creates a new Connection object from existing Sqlx.DB.
func NewConnectionFromString ¶
func NewConnectionFromString(driver string, connectionString string) *Connection
NewConnectionFromString instantiates a Connection from a given driver and connection string.
func (*Connection) Begin ¶
func (conn *Connection) Begin() (*Tx, error)
Begin creates a transaction for the given session
func (*Connection) MustCreateMetaTable ¶
func (con *Connection) MustCreateMetaTable()
MustCreateMetaTable creates the dat__meta table or panics.
func (*Connection) MustRegisterFunction ¶
func (con *Connection) MustRegisterFunction(name string, version string, body string)
MustRegisterFunction registers a user defined function but will not recreate it unles the hash has changed with version. This is useful for keeping user defined functions defined in source code.
func (*Connection) NewSession ¶
func (cxn *Connection) NewSession() (*Session, error)
NewSession instantiates a Session for the Connection
type Execer ¶
type Execer struct {
// contains filtered or unexported fields
}
Execer implements dat.Execer
func NewExecer ¶
func NewExecer(runner runner, builder dat.Builder) *Execer
NewExecer creates a new instance of Execer.
func (*Execer) QueryJSON ¶
QueryJSON wraps the builder's query within a `to_json` then executes and returns the JSON []byte representation.
func (*Execer) QueryObject ¶
QueryObject wraps the builder's query within a `to_json` then executes and unmarshals the result into dest.
func (*Execer) QueryScalar ¶
QueryScalar executes builder's query and scans returned row into destinations.
func (*Execer) QuerySlice ¶
QuerySlice executes builder's query and builds a slice of values from each row, where each row only has one column.
func (*Execer) QueryStruct ¶
QueryStruct executes builders' query and scans the result row into dest.
func (*Execer) QueryStructs ¶
QueryStructs executes builders' query and scans each row as an item in a slice of structs.
type IQueryable ¶
type IQueryable interface { DeleteFrom(table string) *dat.DeleteBuilder Exec(cmd string, args ...interface{}) (*dat.Result, error) ExecBuilder(b dat.Builder) error ExecMulti(commands ...*dat.Expression) (int, error) InsertInto(table string) *dat.InsertBuilder Insect(table string) *dat.InsectBuilder Select(columns ...string) *dat.SelectBuilder SelectDoc(columns ...string) *dat.SelectDocBuilder SQL(sql string, args ...interface{}) *dat.RawBuilder Update(table string) *dat.UpdateBuilder Upsert(table string) *dat.UpsertBuilder }
IQueryable is an object that can be queried.
type Queryable ¶
type Queryable struct {
// contains filtered or unexported fields
}
Queryable is an object that can be queried.
func WrapSqlxExt ¶
WrapSqlxExt converts a sqlx.Ext to a *Queryable
func (*Queryable) DeleteFrom ¶
DeleteFrom creates a new DeleteBuilder for the given table.
func (*Queryable) ExecBuilder ¶
ExecBuilder executes the SQL in builder.
func (*Queryable) ExecMulti ¶
ExecMulti executes multiple SQL statements returning the number of statements executed, or the index at which an error occurred.
func (*Queryable) InsertInto ¶
InsertInto creates a new InsertBuilder for the given table.
type Session ¶
type Session struct {
*Tx
}
Session represents a business unit of execution for some connection
type Tx ¶
Tx is a transaction for the given Session
func (*Tx) AutoCommit ¶
AutoCommit commits a transaction IF neither Commit or Rollback were called.
func (*Tx) AutoRollback ¶
AutoRollback rolls back transaction IF neither Commit or Rollback were called.