package bun

Import Path
	github.com/uptrace/bun (on go.dev)

Dependency Relation
	imports 18 packages, and imported by 3 packages


Package-Level Type Names (total 67, in which 42 are exported)
/* sort exporteds by: | */
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) ColumnExpr(query string, args ...interface{}) *AddColumnQuery (*T) Conn(db IConn) *AddColumnQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) Model(model interface{}) *AddColumnQuery (*T) ModelTableExpr(query string, args ...interface{}) *AddColumnQuery (*T) Operation() string (*T) Table(tables ...string) *AddColumnQuery (*T) TableExpr(query string, args ...interface{}) *AddColumnQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewAddColumnQuery(db *DB) *AddColumnQuery func (*AddColumnQuery).ColumnExpr(query string, args ...interface{}) *AddColumnQuery func (*AddColumnQuery).Conn(db IConn) *AddColumnQuery func (*AddColumnQuery).Model(model interface{}) *AddColumnQuery func (*AddColumnQuery).ModelTableExpr(query string, args ...interface{}) *AddColumnQuery func (*AddColumnQuery).Table(tables ...string) *AddColumnQuery func (*AddColumnQuery).TableExpr(query string, args ...interface{}) *AddColumnQuery func Conn.NewAddColumn() *AddColumnQuery func (*DB).NewAddColumn() *AddColumnQuery func IDB.NewAddColumn() *AddColumnQuery func Tx.NewAddColumn() *AddColumnQuery
( T) AfterCreateTable(ctx context.Context, query *CreateTableQuery) error
( T) AfterDelete(ctx context.Context, query *DeleteQuery) error
( T) AfterDropTable(ctx context.Context, query *DropTableQuery) error
( T) AfterInsert(ctx context.Context, query *InsertQuery) error
type AfterScanHook = schema.AfterScanHook (interface)
( T) AfterSelect(ctx context.Context, query *SelectQuery) error
( T) AfterUpdate(ctx context.Context, query *UpdateQuery) error
type BaseModel = schema.BaseModel (struct)
( T) BeforeCreateTable(ctx context.Context, query *CreateTableQuery) error
( T) BeforeDelete(ctx context.Context, query *DeleteQuery) error
( T) BeforeDropTable(ctx context.Context, query *DropTableQuery) error
( T) BeforeInsert(ctx context.Context, query *InsertQuery) error
( T) BeforeSelect(ctx context.Context, query *SelectQuery) error
( T) BeforeUpdate(ctx context.Context, query *UpdateQuery) error
Conn *sql.Conn BeginTx starts a transaction. The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the context provided to BeginTx is canceled. The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned. Close returns the connection to the connection pool. All operations after a Close will return with ErrConnDone. Close is safe to call concurrently with other operations and will block until all other operations finish. It may be useful to first cancel any used context and then call close directly after. ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ( T) NewAddColumn() *AddColumnQuery ( T) NewCreateIndex() *CreateIndexQuery ( T) NewCreateTable() *CreateTableQuery ( T) NewDelete() *DeleteQuery ( T) NewDropColumn() *DropColumnQuery ( T) NewDropIndex() *DropIndexQuery ( T) NewDropTable() *DropTableQuery ( T) NewInsert() *InsertQuery ( T) NewSelect() *SelectQuery ( T) NewTruncateTable() *TruncateTableQuery ( T) NewUpdate() *UpdateQuery ( T) NewValues(model interface{}) *ValuesQuery PingContext verifies the connection to the database is still alive. PrepareContext creates a prepared statement for later queries or executions. Multiple queries or executions may be run concurrently from the returned statement. The caller must call the statement's Close method when the statement is no longer needed. The provided context is used for the preparation of the statement, not for the execution of the statement. ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Raw executes f exposing the underlying driver connection for the duration of f. The driverConn must not be used outside of f. Once f returns and err is nil, the Conn will continue to be usable until Conn.Close is called. T : IConn T : IDB T : io.Closer func (*DB).Conn(ctx context.Context) (Conn, error)
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Column(columns ...string) *CreateIndexQuery (*T) ColumnExpr(query string, args ...interface{}) *CreateIndexQuery (*T) Concurrently() *CreateIndexQuery (*T) Conn(db IConn) *CreateIndexQuery (*T) DB() *DB (*T) ExcludeColumn(columns ...string) *CreateIndexQuery (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) IfNotExists() *CreateIndexQuery (*T) Include(columns ...string) *CreateIndexQuery (*T) IncludeExpr(query string, args ...interface{}) *CreateIndexQuery (*T) Index(query string) *CreateIndexQuery (*T) IndexExpr(query string, args ...interface{}) *CreateIndexQuery (*T) Model(model interface{}) *CreateIndexQuery (*T) ModelTableExpr(query string, args ...interface{}) *CreateIndexQuery (*T) Operation() string (*T) Table(tables ...string) *CreateIndexQuery (*T) TableExpr(query string, args ...interface{}) *CreateIndexQuery (*T) Unique() *CreateIndexQuery (*T) Using(query string, args ...interface{}) *CreateIndexQuery (*T) Where(query string, args ...interface{}) *CreateIndexQuery (*T) WhereOr(query string, args ...interface{}) *CreateIndexQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewCreateIndexQuery(db *DB) *CreateIndexQuery func Conn.NewCreateIndex() *CreateIndexQuery func (*CreateIndexQuery).Column(columns ...string) *CreateIndexQuery func (*CreateIndexQuery).ColumnExpr(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Concurrently() *CreateIndexQuery func (*CreateIndexQuery).Conn(db IConn) *CreateIndexQuery func (*CreateIndexQuery).ExcludeColumn(columns ...string) *CreateIndexQuery func (*CreateIndexQuery).IfNotExists() *CreateIndexQuery func (*CreateIndexQuery).Include(columns ...string) *CreateIndexQuery func (*CreateIndexQuery).IncludeExpr(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Index(query string) *CreateIndexQuery func (*CreateIndexQuery).IndexExpr(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Model(model interface{}) *CreateIndexQuery func (*CreateIndexQuery).ModelTableExpr(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Table(tables ...string) *CreateIndexQuery func (*CreateIndexQuery).TableExpr(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Unique() *CreateIndexQuery func (*CreateIndexQuery).Using(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).Where(query string, args ...interface{}) *CreateIndexQuery func (*CreateIndexQuery).WhereOr(query string, args ...interface{}) *CreateIndexQuery func (*DB).NewCreateIndex() *CreateIndexQuery func IDB.NewCreateIndex() *CreateIndexQuery func Tx.NewCreateIndex() *CreateIndexQuery
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Conn(db IConn) *CreateTableQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) ForeignKey(query string, args ...interface{}) *CreateTableQuery (*T) GetModel() Model (*T) IfNotExists() *CreateTableQuery (*T) Model(model interface{}) *CreateTableQuery (*T) ModelTableExpr(query string, args ...interface{}) *CreateTableQuery (*T) Operation() string (*T) Table(tables ...string) *CreateTableQuery (*T) TableExpr(query string, args ...interface{}) *CreateTableQuery (*T) Temp() *CreateTableQuery (*T) Varchar(n int) *CreateTableQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewCreateTableQuery(db *DB) *CreateTableQuery func Conn.NewCreateTable() *CreateTableQuery func (*CreateTableQuery).Conn(db IConn) *CreateTableQuery func (*CreateTableQuery).ForeignKey(query string, args ...interface{}) *CreateTableQuery func (*CreateTableQuery).IfNotExists() *CreateTableQuery func (*CreateTableQuery).Model(model interface{}) *CreateTableQuery func (*CreateTableQuery).ModelTableExpr(query string, args ...interface{}) *CreateTableQuery func (*CreateTableQuery).Table(tables ...string) *CreateTableQuery func (*CreateTableQuery).TableExpr(query string, args ...interface{}) *CreateTableQuery func (*CreateTableQuery).Temp() *CreateTableQuery func (*CreateTableQuery).Varchar(n int) *CreateTableQuery func (*DB).NewCreateTable() *CreateTableQuery func IDB.NewCreateTable() *CreateTableQuery func Tx.NewCreateTable() *CreateTableQuery func AfterCreateTableHook.AfterCreateTable(ctx context.Context, query *CreateTableQuery) error func BeforeCreateTableHook.BeforeCreateTable(ctx context.Context, query *CreateTableQuery) error
DB *sql.DB (*T) AddQueryHook(hook QueryHook) (*T) Begin() (Tx, error) (*T) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error) Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish. It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines. (*T) Conn(ctx context.Context) (Conn, error) (*T) DBStats() DBStats (*T) Dialect() schema.Dialect Driver returns the database's underlying driver. (*T) Exec(query string, args ...interface{}) (sql.Result, error) (*T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) (*T) Formatter() schema.Formatter (*T) NewAddColumn() *AddColumnQuery (*T) NewCreateIndex() *CreateIndexQuery (*T) NewCreateTable() *CreateTableQuery (*T) NewDelete() *DeleteQuery (*T) NewDropColumn() *DropColumnQuery (*T) NewDropIndex() *DropIndexQuery (*T) NewDropTable() *DropTableQuery (*T) NewInsert() *InsertQuery (*T) NewSelect() *SelectQuery (*T) NewTruncateTable() *TruncateTableQuery (*T) NewUpdate() *UpdateQuery (*T) NewValues(model interface{}) *ValuesQuery Ping verifies a connection to the database is still alive, establishing a connection if necessary. PingContext verifies a connection to the database is still alive, establishing a connection if necessary. (*T) Prepare(query string) (Stmt, error) (*T) PrepareContext(ctx context.Context, query string) (Stmt, error) (*T) Query(query string, args ...interface{}) (*sql.Rows, error) (*T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) (*T) QueryRow(query string, args ...interface{}) *sql.Row (*T) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row (*T) RegisterModel(models ...interface{}) (*T) ResetModel(ctx context.Context, models ...interface{}) error RunInTx runs the function in a transaction. If the function returns an error, the transaction is rolled back. Otherwise, the transaction is committed. (*T) ScanRow(ctx context.Context, rows *sql.Rows, dest ...interface{}) error (*T) ScanRows(ctx context.Context, rows *sql.Rows, dest ...interface{}) error SetConnMaxIdleTime sets the maximum amount of time a connection may be idle. Expired connections may be closed lazily before reuse. If d <= 0, connections are not closed due to a connection's idle time. SetConnMaxLifetime sets the maximum amount of time a connection may be reused. Expired connections may be closed lazily before reuse. If d <= 0, connections are not closed due to a connection's age. SetMaxIdleConns sets the maximum number of connections in the idle connection pool. If MaxOpenConns is greater than 0 but less than the new MaxIdleConns, then the new MaxIdleConns will be reduced to match the MaxOpenConns limit. If n <= 0, no idle connections are retained. The default max idle connections is currently 2. This may change in a future release. SetMaxOpenConns sets the maximum number of open connections to the database. If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than MaxIdleConns, then MaxIdleConns will be reduced to match the new MaxOpenConns limit. If n <= 0, then there is no limit on the number of open connections. The default is 0 (unlimited). Stats returns database statistics. (*T) String() string (*T) Table(typ reflect.Type) *schema.Table (*T) WithNamedArg(name string, value interface{}) *DB *T : IConn *T : IDB *T : fmt.Stringer T : io.Closer func NewDB(sqldb *sql.DB, dialect schema.Dialect, opts ...DBOption) *DB func (*DB).WithNamedArg(name string, value interface{}) *DB func github.com/Golang-Tools/sqlhelper.NewDB(URL string, dopts *sqlhelper.Options) (*DB, error) func NewAddColumnQuery(db *DB) *AddColumnQuery func NewCreateIndexQuery(db *DB) *CreateIndexQuery func NewCreateTableQuery(db *DB) *CreateTableQuery func NewDeleteQuery(db *DB) *DeleteQuery func NewDropColumnQuery(db *DB) *DropColumnQuery func NewDropIndexQuery(db *DB) *DropIndexQuery func NewDropTableQuery(db *DB) *DropTableQuery func NewInsertQuery(db *DB) *InsertQuery func NewSelectQuery(db *DB) *SelectQuery func NewTruncateTableQuery(db *DB) *TruncateTableQuery func NewUpdateQuery(db *DB) *UpdateQuery func NewValuesQuery(db *DB, model interface{}) *ValuesQuery func github.com/uptrace/bun/driver/pgdriver.NewListener(db *DB) *pgdriver.Listener func github.com/Golang-Tools/sqlhelper.WithInstance(cli *DB) sqlhelper.Option func github.com/Golang-Tools/sqlhelper.(*Proxy).SetConnect(cli *DB, parallelcallback bool) error
func WithDiscardUnknownColumns() DBOption func NewDB(sqldb *sql.DB, dialect schema.Dialect, opts ...DBOption) *DB
Errors uint64 Queries uint64 func (*DB).DBStats() DBStats
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) Apply calls the fn passing the DeleteQuery as an argument. (*T) Conn(db IConn) *DeleteQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) ForceDelete() *DeleteQuery (*T) GetModel() Model (*T) Model(model interface{}) *DeleteQuery (*T) ModelTableExpr(query string, args ...interface{}) *DeleteQuery (*T) Operation() string Returning adds a RETURNING clause to the query. To suppress the auto-generated RETURNING clause, use `Returning("NULL")`. (*T) Table(tables ...string) *DeleteQuery (*T) TableExpr(query string, args ...interface{}) *DeleteQuery (*T) Where(query string, args ...interface{}) *DeleteQuery (*T) WhereAllWithDeleted() *DeleteQuery (*T) WhereDeleted() *DeleteQuery (*T) WhereGroup(sep string, fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery (*T) WhereOr(query string, args ...interface{}) *DeleteQuery (*T) WherePK() *DeleteQuery (*T) With(name string, query schema.QueryAppender) *DeleteQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewDeleteQuery(db *DB) *DeleteQuery func Conn.NewDelete() *DeleteQuery func (*DB).NewDelete() *DeleteQuery func (*DeleteQuery).Apply(fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery func (*DeleteQuery).Conn(db IConn) *DeleteQuery func (*DeleteQuery).ForceDelete() *DeleteQuery func (*DeleteQuery).Model(model interface{}) *DeleteQuery func (*DeleteQuery).ModelTableExpr(query string, args ...interface{}) *DeleteQuery func (*DeleteQuery).Returning(query string, args ...interface{}) *DeleteQuery func (*DeleteQuery).Table(tables ...string) *DeleteQuery func (*DeleteQuery).TableExpr(query string, args ...interface{}) *DeleteQuery func (*DeleteQuery).Where(query string, args ...interface{}) *DeleteQuery func (*DeleteQuery).WhereAllWithDeleted() *DeleteQuery func (*DeleteQuery).WhereDeleted() *DeleteQuery func (*DeleteQuery).WhereGroup(sep string, fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery func (*DeleteQuery).WhereOr(query string, args ...interface{}) *DeleteQuery func (*DeleteQuery).WherePK() *DeleteQuery func (*DeleteQuery).With(name string, query schema.QueryAppender) *DeleteQuery func IDB.NewDelete() *DeleteQuery func Tx.NewDelete() *DeleteQuery func AfterDeleteHook.AfterDelete(ctx context.Context, query *DeleteQuery) error func BeforeDeleteHook.BeforeDelete(ctx context.Context, query *DeleteQuery) error
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Column(columns ...string) *DropColumnQuery (*T) ColumnExpr(query string, args ...interface{}) *DropColumnQuery (*T) Conn(db IConn) *DropColumnQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) Model(model interface{}) *DropColumnQuery (*T) ModelTableExpr(query string, args ...interface{}) *DropColumnQuery (*T) Operation() string (*T) Table(tables ...string) *DropColumnQuery (*T) TableExpr(query string, args ...interface{}) *DropColumnQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewDropColumnQuery(db *DB) *DropColumnQuery func Conn.NewDropColumn() *DropColumnQuery func (*DB).NewDropColumn() *DropColumnQuery func (*DropColumnQuery).Column(columns ...string) *DropColumnQuery func (*DropColumnQuery).ColumnExpr(query string, args ...interface{}) *DropColumnQuery func (*DropColumnQuery).Conn(db IConn) *DropColumnQuery func (*DropColumnQuery).Model(model interface{}) *DropColumnQuery func (*DropColumnQuery).ModelTableExpr(query string, args ...interface{}) *DropColumnQuery func (*DropColumnQuery).Table(tables ...string) *DropColumnQuery func (*DropColumnQuery).TableExpr(query string, args ...interface{}) *DropColumnQuery func IDB.NewDropColumn() *DropColumnQuery func Tx.NewDropColumn() *DropColumnQuery
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Concurrently() *DropIndexQuery (*T) Conn(db IConn) *DropIndexQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) IfExists() *DropIndexQuery (*T) Index(query string, args ...interface{}) *DropIndexQuery (*T) Model(model interface{}) *DropIndexQuery (*T) Operation() string (*T) Restrict() *DropIndexQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewDropIndexQuery(db *DB) *DropIndexQuery func Conn.NewDropIndex() *DropIndexQuery func (*DB).NewDropIndex() *DropIndexQuery func (*DropIndexQuery).Concurrently() *DropIndexQuery func (*DropIndexQuery).Conn(db IConn) *DropIndexQuery func (*DropIndexQuery).IfExists() *DropIndexQuery func (*DropIndexQuery).Index(query string, args ...interface{}) *DropIndexQuery func (*DropIndexQuery).Model(model interface{}) *DropIndexQuery func (*DropIndexQuery).Restrict() *DropIndexQuery func IDB.NewDropIndex() *DropIndexQuery func Tx.NewDropIndex() *DropIndexQuery
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Conn(db IConn) *DropTableQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) IfExists() *DropTableQuery (*T) Model(model interface{}) *DropTableQuery (*T) ModelTableExpr(query string, args ...interface{}) *DropTableQuery (*T) Operation() string (*T) Restrict() *DropTableQuery (*T) Table(tables ...string) *DropTableQuery (*T) TableExpr(query string, args ...interface{}) *DropTableQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewDropTableQuery(db *DB) *DropTableQuery func Conn.NewDropTable() *DropTableQuery func (*DB).NewDropTable() *DropTableQuery func (*DropTableQuery).Conn(db IConn) *DropTableQuery func (*DropTableQuery).IfExists() *DropTableQuery func (*DropTableQuery).Model(model interface{}) *DropTableQuery func (*DropTableQuery).ModelTableExpr(query string, args ...interface{}) *DropTableQuery func (*DropTableQuery).Restrict() *DropTableQuery func (*DropTableQuery).Table(tables ...string) *DropTableQuery func (*DropTableQuery).TableExpr(query string, args ...interface{}) *DropTableQuery func IDB.NewDropTable() *DropTableQuery func Tx.NewDropTable() *DropTableQuery func AfterDropTableHook.AfterDropTable(ctx context.Context, query *DropTableQuery) error func BeforeDropTableHook.BeforeDropTable(ctx context.Context, query *DropTableQuery) error
IConn is a common interface for *sql.DB, *sql.Conn, and *sql.Tx. ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Conn *DB IDB (interface) Tx github.com/Golang-Tools/sqlhelper.Proxy *database/sql.Conn *database/sql.DB *database/sql.Tx func (*AddColumnQuery).Conn(db IConn) *AddColumnQuery func (*CreateIndexQuery).Conn(db IConn) *CreateIndexQuery func (*CreateTableQuery).Conn(db IConn) *CreateTableQuery func (*DeleteQuery).Conn(db IConn) *DeleteQuery func (*DropColumnQuery).Conn(db IConn) *DropColumnQuery func (*DropIndexQuery).Conn(db IConn) *DropIndexQuery func (*DropTableQuery).Conn(db IConn) *DropTableQuery func (*InsertQuery).Conn(db IConn) *InsertQuery func (*SelectQuery).Conn(db IConn) *SelectQuery func (*TruncateTableQuery).Conn(db IConn) *TruncateTableQuery func (*UpdateQuery).Conn(db IConn) *UpdateQuery func (*ValuesQuery).Conn(db IConn) *ValuesQuery
IDB is a common interface for *bun.DB, bun.Conn, and bun.Tx. ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ( T) NewAddColumn() *AddColumnQuery ( T) NewCreateIndex() *CreateIndexQuery ( T) NewCreateTable() *CreateTableQuery ( T) NewDelete() *DeleteQuery ( T) NewDropColumn() *DropColumnQuery ( T) NewDropIndex() *DropIndexQuery ( T) NewDropTable() *DropTableQuery ( T) NewInsert() *InsertQuery ( T) NewSelect() *SelectQuery ( T) NewTruncateTable() *TruncateTableQuery ( T) NewUpdate() *UpdateQuery ( T) NewValues(model interface{}) *ValuesQuery ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Conn *DB Tx github.com/Golang-Tools/sqlhelper.Proxy T : IConn
type Ident = schema.Ident (basic type)
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) Apply calls the fn passing the SelectQuery as an argument. (*T) Column(columns ...string) *InsertQuery (*T) Conn(db IConn) *InsertQuery (*T) DB() *DB (*T) ExcludeColumn(columns ...string) *InsertQuery (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model Ignore generates an `INSERT IGNORE INTO` query (MySQL). (*T) Model(model interface{}) *InsertQuery (*T) ModelTableExpr(query string, args ...interface{}) *InsertQuery (*T) On(s string, args ...interface{}) *InsertQuery (*T) Operation() string Replaces generates a `REPLACE INTO` query (MySQL). Returning adds a RETURNING clause to the query. To suppress the auto-generated RETURNING clause, use `Returning("NULL")`. (*T) Set(query string, args ...interface{}) *InsertQuery (*T) Table(tables ...string) *InsertQuery (*T) TableExpr(query string, args ...interface{}) *InsertQuery Value overwrites model value for the column. (*T) Where(query string, args ...interface{}) *InsertQuery (*T) WhereOr(query string, args ...interface{}) *InsertQuery (*T) With(name string, query schema.QueryAppender) *InsertQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewInsertQuery(db *DB) *InsertQuery func Conn.NewInsert() *InsertQuery func (*DB).NewInsert() *InsertQuery func IDB.NewInsert() *InsertQuery func (*InsertQuery).Apply(fn func(*InsertQuery) *InsertQuery) *InsertQuery func (*InsertQuery).Column(columns ...string) *InsertQuery func (*InsertQuery).Conn(db IConn) *InsertQuery func (*InsertQuery).ExcludeColumn(columns ...string) *InsertQuery func (*InsertQuery).Ignore() *InsertQuery func (*InsertQuery).Model(model interface{}) *InsertQuery func (*InsertQuery).ModelTableExpr(query string, args ...interface{}) *InsertQuery func (*InsertQuery).On(s string, args ...interface{}) *InsertQuery func (*InsertQuery).Replace() *InsertQuery func (*InsertQuery).Returning(query string, args ...interface{}) *InsertQuery func (*InsertQuery).Set(query string, args ...interface{}) *InsertQuery func (*InsertQuery).Table(tables ...string) *InsertQuery func (*InsertQuery).TableExpr(query string, args ...interface{}) *InsertQuery func (*InsertQuery).Value(column string, expr string, args ...interface{}) *InsertQuery func (*InsertQuery).Where(query string, args ...interface{}) *InsertQuery func (*InsertQuery).WhereOr(query string, args ...interface{}) *InsertQuery func (*InsertQuery).With(name string, query schema.QueryAppender) *InsertQuery func Tx.NewInsert() *InsertQuery func AfterInsertHook.AfterInsert(ctx context.Context, query *InsertQuery) error func BeforeInsertHook.BeforeInsert(ctx context.Context, query *InsertQuery) error
( T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) T : github.com/uptrace/bun/schema.QueryAppender func In(slice interface{}) InValues
( T) ScanRows(ctx context.Context, rows *sql.Rows) (int, error) ( T) Value() interface{}
type NullTime = schema.NullTime (struct)
DB *DB Err error Query string QueryAppender schema.Query QueryArgs []interface{} Result sql.Result StartTime time.Time Stash map[interface{}]interface{} (*T) Operation() string func QueryHook.AfterQuery(context.Context, *QueryEvent) func QueryHook.BeforeQuery(context.Context, *QueryEvent) context.Context func github.com/oiime/logrusbun.(*QueryHook).AfterQuery(ctx context.Context, event *QueryEvent) func github.com/oiime/logrusbun.(*QueryHook).BeforeQuery(ctx context.Context, event *QueryEvent) context.Context
( T) AfterQuery(context.Context, *QueryEvent) ( T) BeforeQuery(context.Context, *QueryEvent) context.Context *github.com/oiime/logrusbun.QueryHook func (*DB).AddQueryHook(hook QueryHook)
type Safe = schema.Safe (basic type)
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) Apply calls the fn passing the SelectQuery as an argument. (*T) Column(columns ...string) *SelectQuery (*T) ColumnExpr(query string, args ...interface{}) *SelectQuery (*T) Conn(db IConn) *SelectQuery (*T) Count(ctx context.Context) (int, error) (*T) DB() *DB (*T) Distinct() *SelectQuery (*T) DistinctOn(query string, args ...interface{}) *SelectQuery (*T) Except(other *SelectQuery) *SelectQuery (*T) ExceptAll(other *SelectQuery) *SelectQuery (*T) ExcludeColumn(columns ...string) *SelectQuery (*T) Exec(ctx context.Context) (res sql.Result, err error) (*T) Exists(ctx context.Context) (bool, error) (*T) For(s string, args ...interface{}) *SelectQuery (*T) GetModel() Model (*T) Group(columns ...string) *SelectQuery (*T) GroupExpr(group string, args ...interface{}) *SelectQuery (*T) Having(having string, args ...interface{}) *SelectQuery (*T) Intersect(other *SelectQuery) *SelectQuery (*T) IntersectAll(other *SelectQuery) *SelectQuery (*T) Join(join string, args ...interface{}) *SelectQuery (*T) JoinOn(cond string, args ...interface{}) *SelectQuery (*T) JoinOnOr(cond string, args ...interface{}) *SelectQuery (*T) Limit(n int) *SelectQuery (*T) Model(model interface{}) *SelectQuery (*T) ModelTableExpr(query string, args ...interface{}) *SelectQuery (*T) Offset(n int) *SelectQuery (*T) Operation() string (*T) Order(orders ...string) *SelectQuery (*T) OrderExpr(query string, args ...interface{}) *SelectQuery Relation adds a relation to the query. (*T) Rows(ctx context.Context) (*sql.Rows, error) (*T) Scan(ctx context.Context, dest ...interface{}) error (*T) ScanAndCount(ctx context.Context, dest ...interface{}) (int, error) (*T) Table(tables ...string) *SelectQuery (*T) TableExpr(query string, args ...interface{}) *SelectQuery (*T) Union(other *SelectQuery) *SelectQuery (*T) UnionAll(other *SelectQuery) *SelectQuery (*T) Where(query string, args ...interface{}) *SelectQuery (*T) WhereAllWithDeleted() *SelectQuery (*T) WhereDeleted() *SelectQuery (*T) WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery (*T) WhereOr(query string, args ...interface{}) *SelectQuery (*T) WherePK() *SelectQuery (*T) With(name string, query schema.QueryAppender) *SelectQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewSelectQuery(db *DB) *SelectQuery func Conn.NewSelect() *SelectQuery func (*DB).NewSelect() *SelectQuery func IDB.NewSelect() *SelectQuery func (*SelectQuery).Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery func (*SelectQuery).Column(columns ...string) *SelectQuery func (*SelectQuery).ColumnExpr(query string, args ...interface{}) *SelectQuery func (*SelectQuery).Conn(db IConn) *SelectQuery func (*SelectQuery).Distinct() *SelectQuery func (*SelectQuery).DistinctOn(query string, args ...interface{}) *SelectQuery func (*SelectQuery).Except(other *SelectQuery) *SelectQuery func (*SelectQuery).ExceptAll(other *SelectQuery) *SelectQuery func (*SelectQuery).ExcludeColumn(columns ...string) *SelectQuery func (*SelectQuery).For(s string, args ...interface{}) *SelectQuery func (*SelectQuery).Group(columns ...string) *SelectQuery func (*SelectQuery).GroupExpr(group string, args ...interface{}) *SelectQuery func (*SelectQuery).Having(having string, args ...interface{}) *SelectQuery func (*SelectQuery).Intersect(other *SelectQuery) *SelectQuery func (*SelectQuery).IntersectAll(other *SelectQuery) *SelectQuery func (*SelectQuery).Join(join string, args ...interface{}) *SelectQuery func (*SelectQuery).JoinOn(cond string, args ...interface{}) *SelectQuery func (*SelectQuery).JoinOnOr(cond string, args ...interface{}) *SelectQuery func (*SelectQuery).Limit(n int) *SelectQuery func (*SelectQuery).Model(model interface{}) *SelectQuery func (*SelectQuery).ModelTableExpr(query string, args ...interface{}) *SelectQuery func (*SelectQuery).Offset(n int) *SelectQuery func (*SelectQuery).Order(orders ...string) *SelectQuery func (*SelectQuery).OrderExpr(query string, args ...interface{}) *SelectQuery func (*SelectQuery).Relation(name string, apply ...func(*SelectQuery) *SelectQuery) *SelectQuery func (*SelectQuery).Table(tables ...string) *SelectQuery func (*SelectQuery).TableExpr(query string, args ...interface{}) *SelectQuery func (*SelectQuery).Union(other *SelectQuery) *SelectQuery func (*SelectQuery).UnionAll(other *SelectQuery) *SelectQuery func (*SelectQuery).Where(query string, args ...interface{}) *SelectQuery func (*SelectQuery).WhereAllWithDeleted() *SelectQuery func (*SelectQuery).WhereDeleted() *SelectQuery func (*SelectQuery).WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery func (*SelectQuery).WhereOr(query string, args ...interface{}) *SelectQuery func (*SelectQuery).WherePK() *SelectQuery func (*SelectQuery).With(name string, query schema.QueryAppender) *SelectQuery func Tx.NewSelect() *SelectQuery func AfterSelectHook.AfterSelect(ctx context.Context, query *SelectQuery) error func BeforeSelectHook.BeforeSelect(ctx context.Context, query *SelectQuery) error func (*SelectQuery).Except(other *SelectQuery) *SelectQuery func (*SelectQuery).ExceptAll(other *SelectQuery) *SelectQuery func (*SelectQuery).Intersect(other *SelectQuery) *SelectQuery func (*SelectQuery).IntersectAll(other *SelectQuery) *SelectQuery func (*SelectQuery).Union(other *SelectQuery) *SelectQuery func (*SelectQuery).UnionAll(other *SelectQuery) *SelectQuery
Stmt *sql.Stmt Close closes the statement. Exec executes a prepared statement with the given arguments and returns a Result summarizing the effect of the statement. ExecContext executes a prepared statement with the given arguments and returns a Result summarizing the effect of the statement. Query executes a prepared query statement with the given arguments and returns the query results as a *Rows. QueryContext executes a prepared query statement with the given arguments and returns the query results as a *Rows. QueryRow executes a prepared query statement with the given arguments. If an error occurs during the execution of the statement, that error will be returned by a call to Scan on the returned *Row, which is always non-nil. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest. Example usage: var name string err := nameByUseridStmt.QueryRow(id).Scan(&name) QueryRowContext executes a prepared query statement with the given arguments. If an error occurs during the execution of the statement, that error will be returned by a call to Scan on the returned *Row, which is always non-nil. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest. T : io.Closer func (*DB).Prepare(query string) (Stmt, error) func (*DB).PrepareContext(ctx context.Context, query string) (Stmt, error)
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Conn(db IConn) *TruncateTableQuery (*T) ContinueIdentity() *TruncateTableQuery (*T) DB() *DB (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) (*T) GetModel() Model (*T) Model(model interface{}) *TruncateTableQuery (*T) Operation() string (*T) Restrict() *TruncateTableQuery (*T) Table(tables ...string) *TruncateTableQuery (*T) TableExpr(query string, args ...interface{}) *TruncateTableQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewTruncateTableQuery(db *DB) *TruncateTableQuery func Conn.NewTruncateTable() *TruncateTableQuery func (*DB).NewTruncateTable() *TruncateTableQuery func IDB.NewTruncateTable() *TruncateTableQuery func (*TruncateTableQuery).Conn(db IConn) *TruncateTableQuery func (*TruncateTableQuery).ContinueIdentity() *TruncateTableQuery func (*TruncateTableQuery).Model(model interface{}) *TruncateTableQuery func (*TruncateTableQuery).Restrict() *TruncateTableQuery func (*TruncateTableQuery).Table(tables ...string) *TruncateTableQuery func (*TruncateTableQuery).TableExpr(query string, args ...interface{}) *TruncateTableQuery func Tx.NewTruncateTable() *TruncateTableQuery
Tx *sql.Tx Commit commits the transaction. ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ( T) NewAddColumn() *AddColumnQuery ( T) NewCreateIndex() *CreateIndexQuery ( T) NewCreateTable() *CreateTableQuery ( T) NewDelete() *DeleteQuery ( T) NewDropColumn() *DropColumnQuery ( T) NewDropIndex() *DropIndexQuery ( T) NewDropTable() *DropTableQuery ( T) NewInsert() *InsertQuery ( T) NewSelect() *SelectQuery ( T) NewTruncateTable() *TruncateTableQuery ( T) NewUpdate() *UpdateQuery ( T) NewValues(model interface{}) *ValuesQuery Prepare creates a prepared statement for use within a transaction. The returned statement operates within the transaction and can no longer be used once the transaction has been committed or rolled back. To use an existing prepared statement on this transaction, see Tx.Stmt. PrepareContext creates a prepared statement for use within a transaction. The returned statement operates within the transaction and will be closed when the transaction has been committed or rolled back. To use an existing prepared statement on this transaction, see Tx.Stmt. The provided context will be used for the preparation of the context, not for the execution of the returned statement. The returned statement will run in the transaction context. ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) *sql.Row ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Rollback aborts the transaction. Stmt returns a transaction-specific prepared statement from an existing statement. Example: updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?") ... tx, err := db.Begin() ... res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203) The returned statement operates within the transaction and will be closed when the transaction has been committed or rolled back. StmtContext returns a transaction-specific prepared statement from an existing statement. Example: updateMoney, err := db.Prepare("UPDATE balance SET money=money+? WHERE id=?") ... tx, err := db.Begin() ... res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203) The provided context is used for the preparation of the statement, not for the execution of the statement. The returned statement operates within the transaction and will be closed when the transaction has been committed or rolled back. T : IConn T : IDB T : database/sql/driver.Tx func (*DB).Begin() (Tx, error) func (*DB).BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
(*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) Apply calls the fn passing the SelectQuery as an argument. (*T) Bulk() *UpdateQuery (*T) Column(columns ...string) *UpdateQuery (*T) Conn(db IConn) *UpdateQuery (*T) DB() *DB (*T) ExcludeColumn(columns ...string) *UpdateQuery (*T) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error) FQN returns a fully qualified column name. For MySQL, it returns the column name with the table alias. For other RDBMS, it returns just the column name. (*T) GetModel() Model (*T) Model(model interface{}) *UpdateQuery (*T) ModelTableExpr(query string, args ...interface{}) *UpdateQuery (*T) Operation() string Returning adds a RETURNING clause to the query. To suppress the auto-generated RETURNING clause, use `Returning("NULL")`. (*T) Set(query string, args ...interface{}) *UpdateQuery (*T) Table(tables ...string) *UpdateQuery (*T) TableExpr(query string, args ...interface{}) *UpdateQuery Value overwrites model value for the column. (*T) Where(query string, args ...interface{}) *UpdateQuery (*T) WhereAllWithDeleted() *UpdateQuery (*T) WhereDeleted() *UpdateQuery (*T) WhereGroup(sep string, fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery (*T) WhereOr(query string, args ...interface{}) *UpdateQuery (*T) WherePK() *UpdateQuery (*T) With(name string, query schema.QueryAppender) *UpdateQuery *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewUpdateQuery(db *DB) *UpdateQuery func Conn.NewUpdate() *UpdateQuery func (*DB).NewUpdate() *UpdateQuery func IDB.NewUpdate() *UpdateQuery func Tx.NewUpdate() *UpdateQuery func (*UpdateQuery).Apply(fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery func (*UpdateQuery).Bulk() *UpdateQuery func (*UpdateQuery).Column(columns ...string) *UpdateQuery func (*UpdateQuery).Conn(db IConn) *UpdateQuery func (*UpdateQuery).ExcludeColumn(columns ...string) *UpdateQuery func (*UpdateQuery).Model(model interface{}) *UpdateQuery func (*UpdateQuery).ModelTableExpr(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).Returning(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).Set(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).Table(tables ...string) *UpdateQuery func (*UpdateQuery).TableExpr(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).Value(column string, expr string, args ...interface{}) *UpdateQuery func (*UpdateQuery).Where(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).WhereAllWithDeleted() *UpdateQuery func (*UpdateQuery).WhereDeleted() *UpdateQuery func (*UpdateQuery).WhereGroup(sep string, fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery func (*UpdateQuery).WhereOr(query string, args ...interface{}) *UpdateQuery func (*UpdateQuery).WherePK() *UpdateQuery func (*UpdateQuery).With(name string, query schema.QueryAppender) *UpdateQuery func AfterUpdateHook.AfterUpdate(ctx context.Context, query *UpdateQuery) error func BeforeUpdateHook.BeforeUpdate(ctx context.Context, query *UpdateQuery) error
AppendColumns appends the table columns. It is used by CTE. (*T) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool) (*T) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error) (*T) Conn(db IConn) *ValuesQuery (*T) DB() *DB (*T) GetModel() Model (*T) Operation() string Value overwrites model value for the column. (*T) WithOrder() *ValuesQuery *T : github.com/uptrace/bun/schema.ColumnsAppender *T : github.com/uptrace/bun/schema.NamedArgAppender *T : github.com/uptrace/bun/schema.Query *T : github.com/uptrace/bun/schema.QueryAppender func NewValuesQuery(db *DB, model interface{}) *ValuesQuery func Conn.NewValues(model interface{}) *ValuesQuery func (*DB).NewValues(model interface{}) *ValuesQuery func IDB.NewValues(model interface{}) *ValuesQuery func Tx.NewValues(model interface{}) *ValuesQuery func (*ValuesQuery).Conn(db IConn) *ValuesQuery func (*ValuesQuery).Value(column string, expr string, args ...interface{}) *ValuesQuery func (*ValuesQuery).WithOrder() *ValuesQuery
Package-Level Functions (total 53, in which 17 are exported)
func In(slice interface{}) InValues
func NewDB(sqldb *sql.DB, dialect schema.Dialect, opts ...DBOption) *DB
func NewValuesQuery(db *DB, model interface{}) *ValuesQuery
SetLogger overwriters default Bun logger.
Version is the current release version.
Package-Level Variables (total 2, neither is exported)
Package-Level Constants (total 5, none are exported)