Documentation ¶
Overview ¶
Package prequel provides PostgreSQL query bulder and executor.
Index ¶
- func SetLogLevel(lvl int)
- func SetLogger(logger Logger)
- type Beginner
- type Conn
- func (conn *Conn) Begin(ctx context.Context) (*Tx, error)
- func (conn *Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (conn *Conn) Close() error
- func (conn *Conn) Exec(ctx context.Context, b builder.Builder) (sql.Result, error)
- func (conn *Conn) ExecRaw(ctx context.Context, sql string, params ...interface{}) (sql.Result, error)
- func (conn *Conn) Get(ctx context.Context, b builder.Builder, dest interface{}) error
- func (conn *Conn) GetRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
- func (conn *Conn) MustBegin(ctx context.Context) *Tx
- func (conn *Conn) MustBeginTx(ctx context.Context, opts *sql.TxOptions) *Tx
- func (conn *Conn) MustExec(ctx context.Context, b builder.Builder) sql.Result
- func (conn *Conn) MustExecRaw(ctx context.Context, sql string, params ...interface{}) sql.Result
- func (conn *Conn) Select(ctx context.Context, b builder.Builder, dest interface{}) error
- func (conn *Conn) SelectRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
- type DB
- func Connect(ctx context.Context, driverName, dataSourceName string) (*DB, error)
- func MustConnect(ctx context.Context, driverName, dataSourceName string) *DB
- func MustOpen(driverName, dataSourceName string) *DB
- func NewDB(db *sql.DB, driverName string) *DB
- func Open(driverName, dataSourceName string) (*DB, error)
- func (db *DB) Begin(ctx context.Context) (*Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
- func (db *DB) Conn(ctx context.Context) (*Conn, error)
- func (db *DB) Exec(ctx context.Context, b builder.Builder) (sql.Result, error)
- func (db *DB) ExecRaw(ctx context.Context, sql string, params ...interface{}) (sql.Result, error)
- func (db *DB) Get(ctx context.Context, b builder.Builder, dest interface{}) error
- func (db *DB) GetRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
- func (db *DB) MustBegin(ctx context.Context) *Tx
- func (db *DB) MustBeginTx(ctx context.Context, opts *sql.TxOptions) *Tx
- func (db *DB) MustConn(ctx context.Context) *Conn
- func (db *DB) MustExec(ctx context.Context, b builder.Builder) sql.Result
- func (db *DB) MustExecRaw(ctx context.Context, sql string, params ...interface{}) sql.Result
- func (db *DB) Select(ctx context.Context, b builder.Builder, dest interface{}) error
- func (db *DB) SelectRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
- type Execer
- type Logger
- type Queryer
- type Runner
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(ctx context.Context, b builder.Builder) (sql.Result, error)
- func (tx *Tx) ExecRaw(ctx context.Context, sql string, params ...interface{}) (sql.Result, error)
- func (tx *Tx) Get(ctx context.Context, b builder.Builder, dest interface{}) error
- func (tx *Tx) GetRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
- func (tx *Tx) MustExec(ctx context.Context, b builder.Builder) sql.Result
- func (tx *Tx) MustExecRaw(ctx context.Context, sql string, params ...interface{}) sql.Result
- func (tx *Tx) Rollback() error
- func (tx *Tx) Select(ctx context.Context, b builder.Builder, dest interface{}) error
- func (tx *Tx) SelectRaw(ctx context.Context, dest interface{}, sql string, params ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLogLevel ¶
func SetLogLevel(lvl int)
Types ¶
type Beginner ¶
type Beginner interface { Begin(ctx context.Context) (*Tx, error) MustBegin(ctx context.Context) *Tx BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) MustBeginTx(ctx context.Context, opts *sql.TxOptions) *Tx }
Beginner is an interface used by Begin and BeginTx (and their Must* variants).
type Conn ¶
Conn is a wrapper around sqlx.Conn which supports builder.Builder.
func (*Conn) MustBegin ¶
MustBegin starts a new transaction using this DB. This method will panic on error.
func (*Conn) MustBeginTx ¶
MustBeginTx starts a new transaction using this DB. This method will panic on error.
func (*Conn) MustExecRaw ¶
type DB ¶
DB is a wrapper around sqlx.DB which supports builder.Builder.
func MustConnect ¶
MustConnect is a wrapper for sqlx.MustConnect that returns *prequel.DB. This method will panic on error.
func MustOpen ¶
MustOpen is a wrapper for sqlx.MustOpen that returns *prequel.DB. This method will panic on error.
func (*DB) Conn ¶
Conn returns a single connection using this DB. Conn will block until either a connection is returned or ctx is canceled. Queries run on the same Conn will be run in the same database session. Every Conn must be returned to the database pool after use by calling Conn.Close.
func (*DB) MustBegin ¶
MustBegin starts a new transaction using this DB. This method will panic on error.
func (*DB) MustBeginTx ¶
MustBeginTx starts a new transaction using this DB. This method will panic on error.
func (*DB) MustConn ¶
Conn returns a single connection using this DB and panic on error. Conn will block until either a connection is returned or ctx is canceled. Queries run on the same Conn will be run in the same database session. Every Conn must be returned to the database pool after use by calling Conn.Close.
func (*DB) MustExecRaw ¶
type Execer ¶
type Execer interface { Exec(ctx context.Context, b builder.Builder) (sql.Result, error) ExecRaw(ctx context.Context, query string, params ...interface{}) (sql.Result, error) MustExec(ctx context.Context, b builder.Builder) sql.Result MustExecRaw(ctx context.Context, query string, params ...interface{}) sql.Result }
Execer is an interface used by Exec and MustExec.
type Queryer ¶
type Queryer interface { Select(ctx context.Context, b builder.Builder, dest interface{}) error SelectRaw(ctx context.Context, dest interface{}, q string, params ...interface{}) error Get(ctx context.Context, b builder.Builder, dest interface{}) error GetRaw(ctx context.Context, dest interface{}, q string, params ...interface{}) error }
Queryer is an interface used by Select and Get
type Tx ¶
Tx is a wrapper around sqlx.Tx which supports builder.Builder.