bun

package module
Version: v1.1.11 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: BSD-2-Clause Imports: 21 Imported by: 270

README

SQL-first Golang ORM for PostgreSQL, MySQL, MSSQL, and SQLite

build workflow PkgGoDev Documentation Chat

Bun is brought to you by ⭐ uptrace/uptrace. Uptrace is an open-source APM tool that supports distributed tracing, metrics, and logs. You can use it to monitor applications and set up automatic alerts to receive notifications via email, Slack, Telegram, and others.

See OpenTelemetry example which demonstrates how you can use Uptrace to monitor Bun.

Features

Resources
Tutorials

Wrote a tutorial for Bun? Create a PR to add here and on Bun site.

Why another database client?

So you can elegantly write complex queries:

regionalSales := db.NewSelect().
	ColumnExpr("region").
	ColumnExpr("SUM(amount) AS total_sales").
	TableExpr("orders").
	GroupExpr("region")

topRegions := db.NewSelect().
	ColumnExpr("region").
	TableExpr("regional_sales").
	Where("total_sales > (SELECT SUM(total_sales) / 10 FROM regional_sales)")

var items []map[string]interface{}
err := db.NewSelect().
	With("regional_sales", regionalSales).
	With("top_regions", topRegions).
	ColumnExpr("region").
	ColumnExpr("product").
	ColumnExpr("SUM(quantity) AS product_units").
	ColumnExpr("SUM(amount) AS product_sales").
	TableExpr("orders").
	Where("region IN (SELECT region FROM top_regions)").
	GroupExpr("region").
	GroupExpr("product").
	Scan(ctx, &items)
WITH regional_sales AS (
    SELECT region, SUM(amount) AS total_sales
    FROM orders
    GROUP BY region
), top_regions AS (
    SELECT region
    FROM regional_sales
    WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales)
)
SELECT region,
       product,
       SUM(quantity) AS product_units,
       SUM(amount) AS product_sales
FROM orders
WHERE region IN (SELECT region FROM top_regions)
GROUP BY region, product

And scan results into scalars, structs, maps, slices of structs/maps/scalars:

users := make([]User, 0)
if err := db.NewSelect().Model(&users).OrderExpr("id ASC").Scan(ctx); err != nil {
	panic(err)
}

user1 := new(User)
if err := db.NewSelect().Model(user1).Where("id = ?", 1).Scan(ctx); err != nil {
	panic(err)
}

See Getting started guide and check examples.

See also

Contributing

See CONTRIBUTING.md for some hints.

And thanks to all the people who already contributed!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func In

func In(slice interface{}) schema.QueryAppender

func SetLogger added in v1.0.0

func SetLogger(logger internal.Logging)

SetLogger overwriters default Bun logger.

func Version added in v0.4.0

func Version() string

Version is the current release version.

Types

type AddColumnQuery

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

func NewAddColumnQuery

func NewAddColumnQuery(db *DB) *AddColumnQuery

func (*AddColumnQuery) AppendNamedArg added in v0.4.0

func (q *AddColumnQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*AddColumnQuery) AppendQuery

func (q *AddColumnQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*AddColumnQuery) Apply added in v1.1.10

func (*AddColumnQuery) ColumnExpr

func (q *AddColumnQuery) ColumnExpr(query string, args ...interface{}) *AddColumnQuery

func (*AddColumnQuery) Conn added in v0.1.14

func (q *AddColumnQuery) Conn(db IConn) *AddColumnQuery

func (*AddColumnQuery) DB

func (q *AddColumnQuery) DB() *DB

func (*AddColumnQuery) Dialect added in v1.0.21

func (q *AddColumnQuery) Dialect() schema.Dialect

func (*AddColumnQuery) Err added in v1.1.10

func (q *AddColumnQuery) Err(err error) *AddColumnQuery

func (*AddColumnQuery) Exec

func (q *AddColumnQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*AddColumnQuery) GetConn added in v1.0.21

func (q *AddColumnQuery) GetConn() IConn

func (*AddColumnQuery) GetModel added in v0.2.0

func (q *AddColumnQuery) GetModel() Model

func (*AddColumnQuery) GetTableName added in v1.0.9

func (q *AddColumnQuery) GetTableName() string

func (*AddColumnQuery) IfNotExists added in v1.0.15

func (q *AddColumnQuery) IfNotExists() *AddColumnQuery

func (*AddColumnQuery) Model

func (q *AddColumnQuery) Model(model interface{}) *AddColumnQuery

func (*AddColumnQuery) ModelTableExpr

func (q *AddColumnQuery) ModelTableExpr(query string, args ...interface{}) *AddColumnQuery

func (*AddColumnQuery) NewAddColumn added in v1.0.21

func (q *AddColumnQuery) NewAddColumn() *AddColumnQuery

func (*AddColumnQuery) NewCreateIndex added in v1.0.21

func (q *AddColumnQuery) NewCreateIndex() *CreateIndexQuery

func (*AddColumnQuery) NewCreateTable added in v1.0.21

func (q *AddColumnQuery) NewCreateTable() *CreateTableQuery

func (*AddColumnQuery) NewDelete added in v1.0.21

func (q *AddColumnQuery) NewDelete() *DeleteQuery

func (*AddColumnQuery) NewDropColumn added in v1.0.21

func (q *AddColumnQuery) NewDropColumn() *DropColumnQuery

func (*AddColumnQuery) NewDropIndex added in v1.0.21

func (q *AddColumnQuery) NewDropIndex() *DropIndexQuery

func (*AddColumnQuery) NewDropTable added in v1.0.21

func (q *AddColumnQuery) NewDropTable() *DropTableQuery

func (*AddColumnQuery) NewInsert added in v1.0.21

func (q *AddColumnQuery) NewInsert() *InsertQuery

func (*AddColumnQuery) NewRaw added in v1.1.8

func (q *AddColumnQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*AddColumnQuery) NewSelect added in v1.0.21

func (q *AddColumnQuery) NewSelect() *SelectQuery

func (*AddColumnQuery) NewTruncateTable added in v1.0.21

func (q *AddColumnQuery) NewTruncateTable() *TruncateTableQuery

func (*AddColumnQuery) NewUpdate added in v1.0.21

func (q *AddColumnQuery) NewUpdate() *UpdateQuery

func (*AddColumnQuery) NewValues added in v1.0.21

func (q *AddColumnQuery) NewValues(model interface{}) *ValuesQuery

func (*AddColumnQuery) Operation added in v1.0.5

func (q *AddColumnQuery) Operation() string

func (*AddColumnQuery) Table

func (q *AddColumnQuery) Table(tables ...string) *AddColumnQuery

func (*AddColumnQuery) TableExpr

func (q *AddColumnQuery) TableExpr(query string, args ...interface{}) *AddColumnQuery

type AfterCreateTableHook added in v0.2.0

type AfterCreateTableHook interface {
	AfterCreateTable(ctx context.Context, query *CreateTableQuery) error
}

type AfterDeleteHook

type AfterDeleteHook interface {
	AfterDelete(ctx context.Context, query *DeleteQuery) error
}

type AfterDropTableHook added in v0.2.0

type AfterDropTableHook interface {
	AfterDropTable(ctx context.Context, query *DropTableQuery) error
}

type AfterInsertHook

type AfterInsertHook interface {
	AfterInsert(ctx context.Context, query *InsertQuery) error
}

type AfterScanHook

type AfterScanHook = schema.AfterScanHook

DEPRECATED. Use AfterScanRowHook instead.

type AfterScanRowHook added in v1.0.13

type AfterScanRowHook = schema.AfterScanRowHook

type AfterSelectHook

type AfterSelectHook interface {
	AfterSelect(ctx context.Context, query *SelectQuery) error
}

type AfterUpdateHook

type AfterUpdateHook interface {
	AfterUpdate(ctx context.Context, query *UpdateQuery) error
}

type BaseModel

type BaseModel = schema.BaseModel

type BeforeAppendModelHook added in v1.0.13

type BeforeAppendModelHook = schema.BeforeAppendModelHook

type BeforeCreateTableHook added in v0.2.0

type BeforeCreateTableHook interface {
	BeforeCreateTable(ctx context.Context, query *CreateTableQuery) error
}

type BeforeDeleteHook

type BeforeDeleteHook interface {
	BeforeDelete(ctx context.Context, query *DeleteQuery) error
}

type BeforeDropTableHook added in v0.2.0

type BeforeDropTableHook interface {
	BeforeDropTable(ctx context.Context, query *DropTableQuery) error
}

type BeforeInsertHook

type BeforeInsertHook interface {
	BeforeInsert(ctx context.Context, query *InsertQuery) error
}

type BeforeScanHook

type BeforeScanHook = schema.BeforeScanHook

DEPRECATED. Use BeforeScanRowHook instead.

type BeforeScanRowHook added in v1.0.13

type BeforeScanRowHook = schema.BeforeScanRowHook

type BeforeSelectHook added in v0.2.0

type BeforeSelectHook interface {
	BeforeSelect(ctx context.Context, query *SelectQuery) error
}

type BeforeUpdateHook

type BeforeUpdateHook interface {
	BeforeUpdate(ctx context.Context, query *UpdateQuery) error
}

type Conn

type Conn struct {
	*sql.Conn
	// contains filtered or unexported fields
}

func (Conn) BeginTx added in v1.1.6

func (c Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

func (Conn) Dialect added in v1.0.20

func (c Conn) Dialect() schema.Dialect

func (Conn) ExecContext

func (c Conn) ExecContext(
	ctx context.Context, query string, args ...interface{},
) (sql.Result, error)

func (Conn) NewAddColumn added in v0.1.12

func (c Conn) NewAddColumn() *AddColumnQuery

func (Conn) NewCreateIndex added in v0.1.12

func (c Conn) NewCreateIndex() *CreateIndexQuery

func (Conn) NewCreateTable added in v0.1.12

func (c Conn) NewCreateTable() *CreateTableQuery

func (Conn) NewDelete added in v0.1.12

func (c Conn) NewDelete() *DeleteQuery

func (Conn) NewDropColumn added in v0.1.12

func (c Conn) NewDropColumn() *DropColumnQuery

func (Conn) NewDropIndex added in v0.1.12

func (c Conn) NewDropIndex() *DropIndexQuery

func (Conn) NewDropTable added in v0.1.12

func (c Conn) NewDropTable() *DropTableQuery

func (Conn) NewInsert added in v0.1.12

func (c Conn) NewInsert() *InsertQuery

func (Conn) NewMerge added in v1.1.10

func (c Conn) NewMerge() *MergeQuery

func (Conn) NewRaw added in v1.1.8

func (c Conn) NewRaw(query string, args ...interface{}) *RawQuery

func (Conn) NewSelect added in v0.1.12

func (c Conn) NewSelect() *SelectQuery

func (Conn) NewTruncateTable added in v0.1.12

func (c Conn) NewTruncateTable() *TruncateTableQuery

func (Conn) NewUpdate added in v0.1.12

func (c Conn) NewUpdate() *UpdateQuery

func (Conn) NewValues added in v0.1.12

func (c Conn) NewValues(model interface{}) *ValuesQuery

func (Conn) QueryContext

func (c Conn) QueryContext(
	ctx context.Context, query string, args ...interface{},
) (*sql.Rows, error)

func (Conn) QueryRowContext

func (c Conn) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (Conn) RunInTx added in v1.1.6

func (c Conn) RunInTx(
	ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, tx Tx) error,
) error

RunInTx runs the function in a transaction. If the function returns an error, the transaction is rolled back. Otherwise, the transaction is committed.

type CreateIndexQuery

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

func NewCreateIndexQuery

func NewCreateIndexQuery(db *DB) *CreateIndexQuery

func (*CreateIndexQuery) AppendQuery

func (q *CreateIndexQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*CreateIndexQuery) Column

func (q *CreateIndexQuery) Column(columns ...string) *CreateIndexQuery

func (*CreateIndexQuery) ColumnExpr

func (q *CreateIndexQuery) ColumnExpr(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Concurrently

func (q *CreateIndexQuery) Concurrently() *CreateIndexQuery

func (*CreateIndexQuery) Conn added in v0.1.14

func (*CreateIndexQuery) Err added in v1.1.10

func (*CreateIndexQuery) ExcludeColumn

func (q *CreateIndexQuery) ExcludeColumn(columns ...string) *CreateIndexQuery

func (*CreateIndexQuery) Exec

func (q *CreateIndexQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*CreateIndexQuery) IfNotExists

func (q *CreateIndexQuery) IfNotExists() *CreateIndexQuery

func (*CreateIndexQuery) Include

func (q *CreateIndexQuery) Include(columns ...string) *CreateIndexQuery

func (*CreateIndexQuery) IncludeExpr

func (q *CreateIndexQuery) IncludeExpr(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Index

func (q *CreateIndexQuery) Index(query string) *CreateIndexQuery

func (*CreateIndexQuery) IndexExpr

func (q *CreateIndexQuery) IndexExpr(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Model

func (q *CreateIndexQuery) Model(model interface{}) *CreateIndexQuery

func (*CreateIndexQuery) ModelTableExpr

func (q *CreateIndexQuery) ModelTableExpr(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Operation added in v1.0.5

func (q *CreateIndexQuery) Operation() string

func (*CreateIndexQuery) Table

func (q *CreateIndexQuery) Table(tables ...string) *CreateIndexQuery

func (*CreateIndexQuery) TableExpr

func (q *CreateIndexQuery) TableExpr(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Unique

func (q *CreateIndexQuery) Unique() *CreateIndexQuery

func (*CreateIndexQuery) Using

func (q *CreateIndexQuery) Using(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) Where

func (q *CreateIndexQuery) Where(query string, args ...interface{}) *CreateIndexQuery

func (*CreateIndexQuery) WhereOr

func (q *CreateIndexQuery) WhereOr(query string, args ...interface{}) *CreateIndexQuery

type CreateTableQuery

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

func NewCreateTableQuery

func NewCreateTableQuery(db *DB) *CreateTableQuery

func (*CreateTableQuery) AppendNamedArg added in v0.4.0

func (q *CreateTableQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*CreateTableQuery) AppendQuery

func (q *CreateTableQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*CreateTableQuery) ColumnExpr added in v1.0.9

func (q *CreateTableQuery) ColumnExpr(query string, args ...interface{}) *CreateTableQuery

func (*CreateTableQuery) Conn added in v0.1.14

func (*CreateTableQuery) DB

func (q *CreateTableQuery) DB() *DB

func (*CreateTableQuery) Dialect added in v1.0.21

func (q *CreateTableQuery) Dialect() schema.Dialect

func (*CreateTableQuery) Err added in v1.1.10

func (*CreateTableQuery) Exec

func (q *CreateTableQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*CreateTableQuery) ForeignKey added in v0.1.13

func (q *CreateTableQuery) ForeignKey(query string, args ...interface{}) *CreateTableQuery

func (*CreateTableQuery) GetConn added in v1.0.21

func (q *CreateTableQuery) GetConn() IConn

func (*CreateTableQuery) GetModel added in v0.2.0

func (q *CreateTableQuery) GetModel() Model

func (*CreateTableQuery) GetTableName added in v1.0.9

func (q *CreateTableQuery) GetTableName() string

func (*CreateTableQuery) IfNotExists

func (q *CreateTableQuery) IfNotExists() *CreateTableQuery

func (*CreateTableQuery) Model

func (q *CreateTableQuery) Model(model interface{}) *CreateTableQuery

func (*CreateTableQuery) ModelTableExpr

func (q *CreateTableQuery) ModelTableExpr(query string, args ...interface{}) *CreateTableQuery

func (*CreateTableQuery) NewAddColumn added in v1.0.21

func (q *CreateTableQuery) NewAddColumn() *AddColumnQuery

func (*CreateTableQuery) NewCreateIndex added in v1.0.21

func (q *CreateTableQuery) NewCreateIndex() *CreateIndexQuery

func (*CreateTableQuery) NewCreateTable added in v1.0.21

func (q *CreateTableQuery) NewCreateTable() *CreateTableQuery

func (*CreateTableQuery) NewDelete added in v1.0.21

func (q *CreateTableQuery) NewDelete() *DeleteQuery

func (*CreateTableQuery) NewDropColumn added in v1.0.21

func (q *CreateTableQuery) NewDropColumn() *DropColumnQuery

func (*CreateTableQuery) NewDropIndex added in v1.0.21

func (q *CreateTableQuery) NewDropIndex() *DropIndexQuery

func (*CreateTableQuery) NewDropTable added in v1.0.21

func (q *CreateTableQuery) NewDropTable() *DropTableQuery

func (*CreateTableQuery) NewInsert added in v1.0.21

func (q *CreateTableQuery) NewInsert() *InsertQuery

func (*CreateTableQuery) NewRaw added in v1.1.8

func (q *CreateTableQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*CreateTableQuery) NewSelect added in v1.0.21

func (q *CreateTableQuery) NewSelect() *SelectQuery

func (*CreateTableQuery) NewTruncateTable added in v1.0.21

func (q *CreateTableQuery) NewTruncateTable() *TruncateTableQuery

func (*CreateTableQuery) NewUpdate added in v1.0.21

func (q *CreateTableQuery) NewUpdate() *UpdateQuery

func (*CreateTableQuery) NewValues added in v1.0.21

func (q *CreateTableQuery) NewValues(model interface{}) *ValuesQuery

func (*CreateTableQuery) Operation added in v1.0.5

func (q *CreateTableQuery) Operation() string

func (*CreateTableQuery) PartitionBy added in v1.0.18

func (q *CreateTableQuery) PartitionBy(query string, args ...interface{}) *CreateTableQuery

func (*CreateTableQuery) Table

func (q *CreateTableQuery) Table(tables ...string) *CreateTableQuery

func (*CreateTableQuery) TableExpr

func (q *CreateTableQuery) TableExpr(query string, args ...interface{}) *CreateTableQuery

func (*CreateTableQuery) TableSpace added in v1.0.18

func (q *CreateTableQuery) TableSpace(tablespace string) *CreateTableQuery

func (*CreateTableQuery) Temp

func (*CreateTableQuery) Varchar

func (q *CreateTableQuery) Varchar(n int) *CreateTableQuery

Varchar sets default length for VARCHAR columns.

func (*CreateTableQuery) WithForeignKeys added in v1.0.23

func (q *CreateTableQuery) WithForeignKeys() *CreateTableQuery

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(sqldb *sql.DB, dialect schema.Dialect, opts ...DBOption) *DB

func (*DB) AddQueryHook

func (db *DB) AddQueryHook(hook QueryHook)

func (*DB) Begin

func (db *DB) Begin() (Tx, error)

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

func (*DB) Conn

func (db *DB) Conn(ctx context.Context) (Conn, error)

func (*DB) DBStats added in v0.1.13

func (db *DB) DBStats() DBStats

func (*DB) Dialect

func (db *DB) Dialect() schema.Dialect

func (*DB) Exec

func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error)

func (*DB) ExecContext

func (db *DB) ExecContext(
	ctx context.Context, query string, args ...interface{},
) (sql.Result, error)

func (*DB) Formatter

func (db *DB) Formatter() schema.Formatter

func (*DB) HasFeature added in v1.0.18

func (db *DB) HasFeature(feat feature.Feature) bool

HasFeature uses feature package to report whether the underlying DBMS supports this feature.

func (*DB) NewAddColumn

func (db *DB) NewAddColumn() *AddColumnQuery

func (*DB) NewCreateIndex

func (db *DB) NewCreateIndex() *CreateIndexQuery

func (*DB) NewCreateTable

func (db *DB) NewCreateTable() *CreateTableQuery

func (*DB) NewDelete

func (db *DB) NewDelete() *DeleteQuery

func (*DB) NewDropColumn

func (db *DB) NewDropColumn() *DropColumnQuery

func (*DB) NewDropIndex

func (db *DB) NewDropIndex() *DropIndexQuery

func (*DB) NewDropTable

func (db *DB) NewDropTable() *DropTableQuery

func (*DB) NewInsert

func (db *DB) NewInsert() *InsertQuery

func (*DB) NewMerge added in v1.1.10

func (db *DB) NewMerge() *MergeQuery

func (*DB) NewRaw added in v1.1.8

func (db *DB) NewRaw(query string, args ...interface{}) *RawQuery

func (*DB) NewSelect

func (db *DB) NewSelect() *SelectQuery

func (*DB) NewTruncateTable

func (db *DB) NewTruncateTable() *TruncateTableQuery

func (*DB) NewUpdate

func (db *DB) NewUpdate() *UpdateQuery

func (*DB) NewValues

func (db *DB) NewValues(model interface{}) *ValuesQuery

func (*DB) Prepare

func (db *DB) Prepare(query string) (Stmt, error)

func (*DB) PrepareContext

func (db *DB) PrepareContext(ctx context.Context, query string) (Stmt, error)

func (*DB) Query

func (db *DB) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*DB) QueryContext

func (db *DB) QueryContext(
	ctx context.Context, query string, args ...interface{},
) (*sql.Rows, error)

func (*DB) QueryRow

func (db *DB) QueryRow(query string, args ...interface{}) *sql.Row

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (*DB) Raw deprecated added in v1.1.6

func (db *DB) Raw(query string, args ...interface{}) *RawQuery

Deprecated: Use NewRaw instead. When add it to IDB, it conflicts with the sql.Conn#Raw

func (*DB) RegisterModel

func (db *DB) RegisterModel(models ...interface{})

RegisterModel registers models by name so they can be referenced in table relations and fixtures.

func (*DB) ResetModel added in v0.1.6

func (db *DB) ResetModel(ctx context.Context, models ...interface{}) error

func (*DB) RunInTx added in v0.2.5

func (db *DB) RunInTx(
	ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context, tx Tx) error,
) error

RunInTx runs the function in a transaction. If the function returns an error, the transaction is rolled back. Otherwise, the transaction is committed.

func (*DB) ScanRow

func (db *DB) ScanRow(ctx context.Context, rows *sql.Rows, dest ...interface{}) error

func (*DB) ScanRows

func (db *DB) ScanRows(ctx context.Context, rows *sql.Rows, dest ...interface{}) error

func (*DB) String added in v0.3.5

func (db *DB) String() string

func (*DB) Table

func (db *DB) Table(typ reflect.Type) *schema.Table

func (*DB) UpdateFQN added in v1.0.19

func (db *DB) UpdateFQN(alias, column string) Ident

UpdateFQN 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.

func (*DB) WithNamedArg

func (db *DB) WithNamedArg(name string, value interface{}) *DB

type DBOption

type DBOption func(db *DB)

func WithDiscardUnknownColumns added in v0.1.3

func WithDiscardUnknownColumns() DBOption

type DBStats

type DBStats struct {
	Queries uint32
	Errors  uint32
}

type DeleteQuery

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

func NewDeleteQuery

func NewDeleteQuery(db *DB) *DeleteQuery

func (*DeleteQuery) AppendQuery

func (q *DeleteQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*DeleteQuery) Apply

func (q *DeleteQuery) Apply(fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery

Apply calls the fn passing the DeleteQuery as an argument.

func (*DeleteQuery) ApplyQueryBuilder added in v1.1.4

func (q *DeleteQuery) ApplyQueryBuilder(fn func(QueryBuilder) QueryBuilder) *DeleteQuery

func (*DeleteQuery) Conn added in v0.1.14

func (q *DeleteQuery) Conn(db IConn) *DeleteQuery

func (*DeleteQuery) Err added in v1.1.10

func (q *DeleteQuery) Err(err error) *DeleteQuery

func (*DeleteQuery) Exec

func (q *DeleteQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*DeleteQuery) ForceDelete

func (q *DeleteQuery) ForceDelete() *DeleteQuery

func (*DeleteQuery) Model

func (q *DeleteQuery) Model(model interface{}) *DeleteQuery

func (*DeleteQuery) ModelTableExpr

func (q *DeleteQuery) ModelTableExpr(query string, args ...interface{}) *DeleteQuery

func (*DeleteQuery) Operation added in v1.0.5

func (q *DeleteQuery) Operation() string

func (*DeleteQuery) QueryBuilder added in v1.1.4

func (q *DeleteQuery) QueryBuilder() QueryBuilder

func (*DeleteQuery) Returning

func (q *DeleteQuery) Returning(query string, args ...interface{}) *DeleteQuery

Returning adds a RETURNING clause to the query.

To suppress the auto-generated RETURNING clause, use `Returning("NULL")`.

func (*DeleteQuery) Scan added in v1.1.10

func (q *DeleteQuery) Scan(ctx context.Context, dest ...interface{}) error

func (*DeleteQuery) String added in v1.1.6

func (q *DeleteQuery) String() string

func (*DeleteQuery) Table

func (q *DeleteQuery) Table(tables ...string) *DeleteQuery

func (*DeleteQuery) TableExpr

func (q *DeleteQuery) TableExpr(query string, args ...interface{}) *DeleteQuery

func (*DeleteQuery) Where

func (q *DeleteQuery) Where(query string, args ...interface{}) *DeleteQuery

func (*DeleteQuery) WhereAllWithDeleted

func (q *DeleteQuery) WhereAllWithDeleted() *DeleteQuery

func (*DeleteQuery) WhereDeleted

func (q *DeleteQuery) WhereDeleted() *DeleteQuery

func (*DeleteQuery) WhereGroup

func (q *DeleteQuery) WhereGroup(sep string, fn func(*DeleteQuery) *DeleteQuery) *DeleteQuery

func (*DeleteQuery) WhereOr

func (q *DeleteQuery) WhereOr(query string, args ...interface{}) *DeleteQuery

func (*DeleteQuery) WherePK

func (q *DeleteQuery) WherePK(cols ...string) *DeleteQuery

func (*DeleteQuery) With

func (q *DeleteQuery) With(name string, query schema.QueryAppender) *DeleteQuery

func (*DeleteQuery) WithRecursive added in v1.1.9

func (q *DeleteQuery) WithRecursive(name string, query schema.QueryAppender) *DeleteQuery

type DropColumnQuery

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

func NewDropColumnQuery

func NewDropColumnQuery(db *DB) *DropColumnQuery

func (*DropColumnQuery) AppendNamedArg added in v0.4.0

func (q *DropColumnQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*DropColumnQuery) AppendQuery

func (q *DropColumnQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*DropColumnQuery) Apply added in v1.1.10

func (*DropColumnQuery) Column

func (q *DropColumnQuery) Column(columns ...string) *DropColumnQuery

func (*DropColumnQuery) ColumnExpr

func (q *DropColumnQuery) ColumnExpr(query string, args ...interface{}) *DropColumnQuery

func (*DropColumnQuery) Conn added in v0.1.14

func (q *DropColumnQuery) Conn(db IConn) *DropColumnQuery

func (*DropColumnQuery) DB

func (q *DropColumnQuery) DB() *DB

func (*DropColumnQuery) Dialect added in v1.0.21

func (q *DropColumnQuery) Dialect() schema.Dialect

func (*DropColumnQuery) Err added in v1.1.10

func (q *DropColumnQuery) Err(err error) *DropColumnQuery

func (*DropColumnQuery) Exec

func (q *DropColumnQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*DropColumnQuery) GetConn added in v1.0.21

func (q *DropColumnQuery) GetConn() IConn

func (*DropColumnQuery) GetModel added in v0.2.0

func (q *DropColumnQuery) GetModel() Model

func (*DropColumnQuery) GetTableName added in v1.0.9

func (q *DropColumnQuery) GetTableName() string

func (*DropColumnQuery) Model

func (q *DropColumnQuery) Model(model interface{}) *DropColumnQuery

func (*DropColumnQuery) ModelTableExpr

func (q *DropColumnQuery) ModelTableExpr(query string, args ...interface{}) *DropColumnQuery

func (*DropColumnQuery) NewAddColumn added in v1.0.21

func (q *DropColumnQuery) NewAddColumn() *AddColumnQuery

func (*DropColumnQuery) NewCreateIndex added in v1.0.21

func (q *DropColumnQuery) NewCreateIndex() *CreateIndexQuery

func (*DropColumnQuery) NewCreateTable added in v1.0.21

func (q *DropColumnQuery) NewCreateTable() *CreateTableQuery

func (*DropColumnQuery) NewDelete added in v1.0.21

func (q *DropColumnQuery) NewDelete() *DeleteQuery

func (*DropColumnQuery) NewDropColumn added in v1.0.21

func (q *DropColumnQuery) NewDropColumn() *DropColumnQuery

func (*DropColumnQuery) NewDropIndex added in v1.0.21

func (q *DropColumnQuery) NewDropIndex() *DropIndexQuery

func (*DropColumnQuery) NewDropTable added in v1.0.21

func (q *DropColumnQuery) NewDropTable() *DropTableQuery

func (*DropColumnQuery) NewInsert added in v1.0.21

func (q *DropColumnQuery) NewInsert() *InsertQuery

func (*DropColumnQuery) NewRaw added in v1.1.8

func (q *DropColumnQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*DropColumnQuery) NewSelect added in v1.0.21

func (q *DropColumnQuery) NewSelect() *SelectQuery

func (*DropColumnQuery) NewTruncateTable added in v1.0.21

func (q *DropColumnQuery) NewTruncateTable() *TruncateTableQuery

func (*DropColumnQuery) NewUpdate added in v1.0.21

func (q *DropColumnQuery) NewUpdate() *UpdateQuery

func (*DropColumnQuery) NewValues added in v1.0.21

func (q *DropColumnQuery) NewValues(model interface{}) *ValuesQuery

func (*DropColumnQuery) Operation added in v1.0.5

func (q *DropColumnQuery) Operation() string

func (*DropColumnQuery) Table

func (q *DropColumnQuery) Table(tables ...string) *DropColumnQuery

func (*DropColumnQuery) TableExpr

func (q *DropColumnQuery) TableExpr(query string, args ...interface{}) *DropColumnQuery

type DropIndexQuery

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

func NewDropIndexQuery

func NewDropIndexQuery(db *DB) *DropIndexQuery

func (*DropIndexQuery) AppendNamedArg added in v0.4.0

func (q *DropIndexQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*DropIndexQuery) AppendQuery

func (q *DropIndexQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*DropIndexQuery) Cascade added in v1.0.20

func (q *DropIndexQuery) Cascade() *DropIndexQuery

func (*DropIndexQuery) Concurrently

func (q *DropIndexQuery) Concurrently() *DropIndexQuery

func (*DropIndexQuery) Conn added in v0.1.14

func (q *DropIndexQuery) Conn(db IConn) *DropIndexQuery

func (*DropIndexQuery) DB

func (q *DropIndexQuery) DB() *DB

func (*DropIndexQuery) Dialect added in v1.0.21

func (q *DropIndexQuery) Dialect() schema.Dialect

func (*DropIndexQuery) Err added in v1.1.10

func (q *DropIndexQuery) Err(err error) *DropIndexQuery

func (*DropIndexQuery) Exec

func (q *DropIndexQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*DropIndexQuery) GetConn added in v1.0.21

func (q *DropIndexQuery) GetConn() IConn

func (*DropIndexQuery) GetModel added in v0.2.0

func (q *DropIndexQuery) GetModel() Model

func (*DropIndexQuery) GetTableName added in v1.0.9

func (q *DropIndexQuery) GetTableName() string

func (*DropIndexQuery) IfExists

func (q *DropIndexQuery) IfExists() *DropIndexQuery

func (*DropIndexQuery) Index

func (q *DropIndexQuery) Index(query string, args ...interface{}) *DropIndexQuery

func (*DropIndexQuery) Model

func (q *DropIndexQuery) Model(model interface{}) *DropIndexQuery

func (*DropIndexQuery) NewAddColumn added in v1.0.21

func (q *DropIndexQuery) NewAddColumn() *AddColumnQuery

func (*DropIndexQuery) NewCreateIndex added in v1.0.21

func (q *DropIndexQuery) NewCreateIndex() *CreateIndexQuery

func (*DropIndexQuery) NewCreateTable added in v1.0.21

func (q *DropIndexQuery) NewCreateTable() *CreateTableQuery

func (*DropIndexQuery) NewDelete added in v1.0.21

func (q *DropIndexQuery) NewDelete() *DeleteQuery

func (*DropIndexQuery) NewDropColumn added in v1.0.21

func (q *DropIndexQuery) NewDropColumn() *DropColumnQuery

func (*DropIndexQuery) NewDropIndex added in v1.0.21

func (q *DropIndexQuery) NewDropIndex() *DropIndexQuery

func (*DropIndexQuery) NewDropTable added in v1.0.21

func (q *DropIndexQuery) NewDropTable() *DropTableQuery

func (*DropIndexQuery) NewInsert added in v1.0.21

func (q *DropIndexQuery) NewInsert() *InsertQuery

func (*DropIndexQuery) NewRaw added in v1.1.8

func (q *DropIndexQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*DropIndexQuery) NewSelect added in v1.0.21

func (q *DropIndexQuery) NewSelect() *SelectQuery

func (*DropIndexQuery) NewTruncateTable added in v1.0.21

func (q *DropIndexQuery) NewTruncateTable() *TruncateTableQuery

func (*DropIndexQuery) NewUpdate added in v1.0.21

func (q *DropIndexQuery) NewUpdate() *UpdateQuery

func (*DropIndexQuery) NewValues added in v1.0.21

func (q *DropIndexQuery) NewValues(model interface{}) *ValuesQuery

func (*DropIndexQuery) Operation added in v1.0.5

func (q *DropIndexQuery) Operation() string

func (*DropIndexQuery) Restrict

func (q *DropIndexQuery) Restrict() *DropIndexQuery

type DropTableQuery

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

func NewDropTableQuery

func NewDropTableQuery(db *DB) *DropTableQuery

func (*DropTableQuery) AppendNamedArg added in v0.4.0

func (q *DropTableQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*DropTableQuery) AppendQuery

func (q *DropTableQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*DropTableQuery) Cascade added in v1.0.20

func (q *DropTableQuery) Cascade() *DropTableQuery

func (*DropTableQuery) Conn added in v0.1.14

func (q *DropTableQuery) Conn(db IConn) *DropTableQuery

func (*DropTableQuery) DB

func (q *DropTableQuery) DB() *DB

func (*DropTableQuery) Dialect added in v1.0.21

func (q *DropTableQuery) Dialect() schema.Dialect

func (*DropTableQuery) Err added in v1.1.10

func (q *DropTableQuery) Err(err error) *DropTableQuery

func (*DropTableQuery) Exec

func (q *DropTableQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*DropTableQuery) GetConn added in v1.0.21

func (q *DropTableQuery) GetConn() IConn

func (*DropTableQuery) GetModel added in v0.2.0

func (q *DropTableQuery) GetModel() Model

func (*DropTableQuery) GetTableName added in v1.0.9

func (q *DropTableQuery) GetTableName() string

func (*DropTableQuery) IfExists

func (q *DropTableQuery) IfExists() *DropTableQuery

func (*DropTableQuery) Model

func (q *DropTableQuery) Model(model interface{}) *DropTableQuery

func (*DropTableQuery) ModelTableExpr added in v0.4.1

func (q *DropTableQuery) ModelTableExpr(query string, args ...interface{}) *DropTableQuery

func (*DropTableQuery) NewAddColumn added in v1.0.21

func (q *DropTableQuery) NewAddColumn() *AddColumnQuery

func (*DropTableQuery) NewCreateIndex added in v1.0.21

func (q *DropTableQuery) NewCreateIndex() *CreateIndexQuery

func (*DropTableQuery) NewCreateTable added in v1.0.21

func (q *DropTableQuery) NewCreateTable() *CreateTableQuery

func (*DropTableQuery) NewDelete added in v1.0.21

func (q *DropTableQuery) NewDelete() *DeleteQuery

func (*DropTableQuery) NewDropColumn added in v1.0.21

func (q *DropTableQuery) NewDropColumn() *DropColumnQuery

func (*DropTableQuery) NewDropIndex added in v1.0.21

func (q *DropTableQuery) NewDropIndex() *DropIndexQuery

func (*DropTableQuery) NewDropTable added in v1.0.21

func (q *DropTableQuery) NewDropTable() *DropTableQuery

func (*DropTableQuery) NewInsert added in v1.0.21

func (q *DropTableQuery) NewInsert() *InsertQuery

func (*DropTableQuery) NewRaw added in v1.1.8

func (q *DropTableQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*DropTableQuery) NewSelect added in v1.0.21

func (q *DropTableQuery) NewSelect() *SelectQuery

func (*DropTableQuery) NewTruncateTable added in v1.0.21

func (q *DropTableQuery) NewTruncateTable() *TruncateTableQuery

func (*DropTableQuery) NewUpdate added in v1.0.21

func (q *DropTableQuery) NewUpdate() *UpdateQuery

func (*DropTableQuery) NewValues added in v1.0.21

func (q *DropTableQuery) NewValues(model interface{}) *ValuesQuery

func (*DropTableQuery) Operation added in v1.0.5

func (q *DropTableQuery) Operation() string

func (*DropTableQuery) Restrict

func (q *DropTableQuery) Restrict() *DropTableQuery

func (*DropTableQuery) Table

func (q *DropTableQuery) Table(tables ...string) *DropTableQuery

func (*DropTableQuery) TableExpr

func (q *DropTableQuery) TableExpr(query string, args ...interface{}) *DropTableQuery

type IConn added in v0.2.1

type IConn interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

IConn is a common interface for *sql.DB, *sql.Conn, and *sql.Tx.

type IDB added in v0.2.1

type IDB interface {
	IConn
	Dialect() schema.Dialect

	NewValues(model interface{}) *ValuesQuery
	NewSelect() *SelectQuery
	NewInsert() *InsertQuery
	NewUpdate() *UpdateQuery
	NewDelete() *DeleteQuery
	NewRaw(query string, args ...interface{}) *RawQuery
	NewCreateTable() *CreateTableQuery
	NewDropTable() *DropTableQuery
	NewCreateIndex() *CreateIndexQuery
	NewDropIndex() *DropIndexQuery
	NewTruncateTable() *TruncateTableQuery
	NewAddColumn() *AddColumnQuery
	NewDropColumn() *DropColumnQuery

	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	RunInTx(ctx context.Context, opts *sql.TxOptions, f func(ctx context.Context, tx Tx) error) error
}

IDB is a common interface for *bun.DB, bun.Conn, and bun.Tx.

type Ident

type Ident = schema.Ident

type InsertQuery

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

func NewInsertQuery

func NewInsertQuery(db *DB) *InsertQuery

func (*InsertQuery) AppendQuery

func (q *InsertQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*InsertQuery) Apply

func (q *InsertQuery) Apply(fn func(*InsertQuery) *InsertQuery) *InsertQuery

Apply calls the fn passing the SelectQuery as an argument.

func (*InsertQuery) Column

func (q *InsertQuery) Column(columns ...string) *InsertQuery

func (*InsertQuery) ColumnExpr added in v1.0.12

func (q *InsertQuery) ColumnExpr(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) Conn added in v0.1.14

func (q *InsertQuery) Conn(db IConn) *InsertQuery

func (*InsertQuery) Err added in v1.1.10

func (q *InsertQuery) Err(err error) *InsertQuery

func (*InsertQuery) ExcludeColumn added in v0.2.0

func (q *InsertQuery) ExcludeColumn(columns ...string) *InsertQuery

func (*InsertQuery) Exec

func (q *InsertQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*InsertQuery) Ignore added in v0.1.9

func (q *InsertQuery) Ignore() *InsertQuery

Ignore generates different queries depending on the DBMS:

  • On MySQL, it generates `INSERT IGNORE INTO`.
  • On PostgreSQL, it generates `ON CONFLICT DO NOTHING`.

func (*InsertQuery) Model

func (q *InsertQuery) Model(model interface{}) *InsertQuery

func (*InsertQuery) ModelTableExpr

func (q *InsertQuery) ModelTableExpr(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) On added in v0.1.9

func (q *InsertQuery) On(s string, args ...interface{}) *InsertQuery

func (*InsertQuery) Operation added in v1.0.5

func (q *InsertQuery) Operation() string

func (*InsertQuery) Replace added in v0.1.9

func (q *InsertQuery) Replace() *InsertQuery

Replaces generates a `REPLACE INTO` query (MySQL and MariaDB).

func (*InsertQuery) Returning

func (q *InsertQuery) Returning(query string, args ...interface{}) *InsertQuery

Returning adds a RETURNING clause to the query.

To suppress the auto-generated RETURNING clause, use `Returning("")`.

func (*InsertQuery) Scan added in v1.1.10

func (q *InsertQuery) Scan(ctx context.Context, dest ...interface{}) error

func (*InsertQuery) Set

func (q *InsertQuery) Set(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) String added in v1.1.6

func (q *InsertQuery) String() string

func (*InsertQuery) Table

func (q *InsertQuery) Table(tables ...string) *InsertQuery

func (*InsertQuery) TableExpr

func (q *InsertQuery) TableExpr(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) Value

func (q *InsertQuery) Value(column string, expr string, args ...interface{}) *InsertQuery

Value overwrites model value for the column.

func (*InsertQuery) Where

func (q *InsertQuery) Where(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) WhereOr

func (q *InsertQuery) WhereOr(query string, args ...interface{}) *InsertQuery

func (*InsertQuery) With

func (q *InsertQuery) With(name string, query schema.QueryAppender) *InsertQuery

func (*InsertQuery) WithRecursive added in v1.1.9

func (q *InsertQuery) WithRecursive(name string, query schema.QueryAppender) *InsertQuery

type MergeQuery added in v1.1.10

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

func NewMergeQuery added in v1.1.10

func NewMergeQuery(db *DB) *MergeQuery

func (*MergeQuery) AppendNamedArg added in v1.1.10

func (q *MergeQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*MergeQuery) AppendQuery added in v1.1.10

func (q *MergeQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*MergeQuery) Apply added in v1.1.10

func (q *MergeQuery) Apply(fn func(*MergeQuery) *MergeQuery) *MergeQuery

Apply calls the fn passing the MergeQuery as an argument.

func (*MergeQuery) Conn added in v1.1.10

func (q *MergeQuery) Conn(db IConn) *MergeQuery

func (*MergeQuery) DB added in v1.1.10

func (q *MergeQuery) DB() *DB

func (*MergeQuery) Dialect added in v1.1.10

func (q *MergeQuery) Dialect() schema.Dialect

func (*MergeQuery) Err added in v1.1.10

func (q *MergeQuery) Err(err error) *MergeQuery

func (*MergeQuery) Exec added in v1.1.10

func (q *MergeQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*MergeQuery) GetConn added in v1.1.10

func (q *MergeQuery) GetConn() IConn

func (*MergeQuery) GetModel added in v1.1.10

func (q *MergeQuery) GetModel() Model

func (*MergeQuery) GetTableName added in v1.1.10

func (q *MergeQuery) GetTableName() string

func (*MergeQuery) Model added in v1.1.10

func (q *MergeQuery) Model(model interface{}) *MergeQuery

func (*MergeQuery) ModelTableExpr added in v1.1.10

func (q *MergeQuery) ModelTableExpr(query string, args ...interface{}) *MergeQuery

func (*MergeQuery) NewAddColumn added in v1.1.10

func (q *MergeQuery) NewAddColumn() *AddColumnQuery

func (*MergeQuery) NewCreateIndex added in v1.1.10

func (q *MergeQuery) NewCreateIndex() *CreateIndexQuery

func (*MergeQuery) NewCreateTable added in v1.1.10

func (q *MergeQuery) NewCreateTable() *CreateTableQuery

func (*MergeQuery) NewDelete added in v1.1.10

func (q *MergeQuery) NewDelete() *DeleteQuery

func (*MergeQuery) NewDropColumn added in v1.1.10

func (q *MergeQuery) NewDropColumn() *DropColumnQuery

func (*MergeQuery) NewDropIndex added in v1.1.10

func (q *MergeQuery) NewDropIndex() *DropIndexQuery

func (*MergeQuery) NewDropTable added in v1.1.10

func (q *MergeQuery) NewDropTable() *DropTableQuery

func (*MergeQuery) NewInsert added in v1.1.10

func (q *MergeQuery) NewInsert() *InsertQuery

func (*MergeQuery) NewRaw added in v1.1.10

func (q *MergeQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*MergeQuery) NewSelect added in v1.1.10

func (q *MergeQuery) NewSelect() *SelectQuery

func (*MergeQuery) NewTruncateTable added in v1.1.10

func (q *MergeQuery) NewTruncateTable() *TruncateTableQuery

func (*MergeQuery) NewUpdate added in v1.1.10

func (q *MergeQuery) NewUpdate() *UpdateQuery

func (*MergeQuery) NewValues added in v1.1.10

func (q *MergeQuery) NewValues(model interface{}) *ValuesQuery

func (*MergeQuery) On added in v1.1.10

func (q *MergeQuery) On(s string, args ...interface{}) *MergeQuery

func (*MergeQuery) Operation added in v1.1.10

func (q *MergeQuery) Operation() string

func (*MergeQuery) Returning added in v1.1.10

func (q *MergeQuery) Returning(query string, args ...interface{}) *MergeQuery

Returning adds a RETURNING clause to the query.

To suppress the auto-generated RETURNING clause, use `Returning("NULL")`. Only for mssql output, postgres not supported returning in merge query

func (*MergeQuery) Scan added in v1.1.10

func (q *MergeQuery) Scan(ctx context.Context, dest ...interface{}) error

func (*MergeQuery) String added in v1.1.10

func (q *MergeQuery) String() string

func (*MergeQuery) Table added in v1.1.10

func (q *MergeQuery) Table(tables ...string) *MergeQuery

func (*MergeQuery) TableExpr added in v1.1.10

func (q *MergeQuery) TableExpr(query string, args ...interface{}) *MergeQuery

func (*MergeQuery) Using added in v1.1.10

func (q *MergeQuery) Using(s string, args ...interface{}) *MergeQuery

func (*MergeQuery) When added in v1.1.10

func (q *MergeQuery) When(expr string, args ...interface{}) *MergeQuery

When for raw expression clause.

func (*MergeQuery) WhenDelete added in v1.1.10

func (q *MergeQuery) WhenDelete(expr string) *MergeQuery

WhenDelete for when delete clause.

func (*MergeQuery) WhenInsert added in v1.1.10

func (q *MergeQuery) WhenInsert(expr string, fn func(q *InsertQuery) *InsertQuery) *MergeQuery

WhenInsert for when insert clause.

func (*MergeQuery) WhenUpdate added in v1.1.10

func (q *MergeQuery) WhenUpdate(expr string, fn func(q *UpdateQuery) *UpdateQuery) *MergeQuery

WhenUpdate for when update clause.

func (*MergeQuery) With added in v1.1.10

func (q *MergeQuery) With(name string, query schema.QueryAppender) *MergeQuery

func (*MergeQuery) WithRecursive added in v1.1.10

func (q *MergeQuery) WithRecursive(name string, query schema.QueryAppender) *MergeQuery

type Model added in v0.2.0

type Model = schema.Model

type NullTime

type NullTime = schema.NullTime

type Query added in v1.0.13

type Query = schema.Query

type QueryBuilder added in v1.1.3

type QueryBuilder interface {
	Query
	Where(query string, args ...interface{}) QueryBuilder
	WhereGroup(sep string, fn func(QueryBuilder) QueryBuilder) QueryBuilder
	WhereOr(query string, args ...interface{}) QueryBuilder
	WhereDeleted() QueryBuilder
	WhereAllWithDeleted() QueryBuilder
	WherePK(cols ...string) QueryBuilder
	Unwrap() interface{}
}

QueryBuilder is used for common query methods

type QueryEvent

type QueryEvent struct {
	DB *DB

	QueryAppender schema.QueryAppender // DEPRECATED: use IQuery instead
	IQuery        Query
	Query         string
	QueryTemplate string
	QueryArgs     []interface{}
	Model         Model

	StartTime time.Time
	Result    sql.Result
	Err       error

	Stash map[interface{}]interface{}
}

func (*QueryEvent) Operation added in v1.0.5

func (e *QueryEvent) Operation() string

type QueryHook

type QueryHook interface {
	BeforeQuery(context.Context, *QueryEvent) context.Context
	AfterQuery(context.Context, *QueryEvent)
}

type RawQuery added in v1.1.6

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

func NewRawQuery added in v1.1.8

func NewRawQuery(db *DB, query string, args ...interface{}) *RawQuery

func (*RawQuery) AppendNamedArg added in v1.1.6

func (q *RawQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*RawQuery) AppendQuery added in v1.1.6

func (q *RawQuery) AppendQuery(fmter schema.Formatter, b []byte) ([]byte, error)

func (*RawQuery) Conn added in v1.1.8

func (q *RawQuery) Conn(db IConn) *RawQuery

func (*RawQuery) DB added in v1.1.6

func (q *RawQuery) DB() *DB

func (*RawQuery) Dialect added in v1.1.6

func (q *RawQuery) Dialect() schema.Dialect

func (*RawQuery) Err added in v1.1.10

func (q *RawQuery) Err(err error) *RawQuery

func (*RawQuery) GetConn added in v1.1.6

func (q *RawQuery) GetConn() IConn

func (*RawQuery) GetModel added in v1.1.6

func (q *RawQuery) GetModel() Model

func (*RawQuery) GetTableName added in v1.1.6

func (q *RawQuery) GetTableName() string

func (*RawQuery) NewAddColumn added in v1.1.6

func (q *RawQuery) NewAddColumn() *AddColumnQuery

func (*RawQuery) NewCreateIndex added in v1.1.6

func (q *RawQuery) NewCreateIndex() *CreateIndexQuery

func (*RawQuery) NewCreateTable added in v1.1.6

func (q *RawQuery) NewCreateTable() *CreateTableQuery

func (*RawQuery) NewDelete added in v1.1.6

func (q *RawQuery) NewDelete() *DeleteQuery

func (*RawQuery) NewDropColumn added in v1.1.6

func (q *RawQuery) NewDropColumn() *DropColumnQuery

func (*RawQuery) NewDropIndex added in v1.1.6

func (q *RawQuery) NewDropIndex() *DropIndexQuery

func (*RawQuery) NewDropTable added in v1.1.6

func (q *RawQuery) NewDropTable() *DropTableQuery

func (*RawQuery) NewInsert added in v1.1.6

func (q *RawQuery) NewInsert() *InsertQuery

func (*RawQuery) NewRaw added in v1.1.8

func (q *RawQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*RawQuery) NewSelect added in v1.1.6

func (q *RawQuery) NewSelect() *SelectQuery

func (*RawQuery) NewTruncateTable added in v1.1.6

func (q *RawQuery) NewTruncateTable() *TruncateTableQuery

func (*RawQuery) NewUpdate added in v1.1.6

func (q *RawQuery) NewUpdate() *UpdateQuery

func (*RawQuery) NewValues added in v1.1.6

func (q *RawQuery) NewValues(model interface{}) *ValuesQuery

func (*RawQuery) Operation added in v1.1.6

func (q *RawQuery) Operation() string

func (*RawQuery) Scan added in v1.1.6

func (q *RawQuery) Scan(ctx context.Context, dest ...interface{}) error

type Safe

type Safe = schema.Safe

type SelectQuery

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

func NewSelectQuery

func NewSelectQuery(db *DB) *SelectQuery

func (*SelectQuery) AppendQuery

func (q *SelectQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*SelectQuery) Apply

func (q *SelectQuery) Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery

Apply calls the fn passing the SelectQuery as an argument.

func (*SelectQuery) ApplyQueryBuilder added in v1.1.4

func (q *SelectQuery) ApplyQueryBuilder(fn func(QueryBuilder) QueryBuilder) *SelectQuery

func (*SelectQuery) Column

func (q *SelectQuery) Column(columns ...string) *SelectQuery

func (*SelectQuery) ColumnExpr

func (q *SelectQuery) ColumnExpr(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) Conn added in v0.1.14

func (q *SelectQuery) Conn(db IConn) *SelectQuery

func (*SelectQuery) Count

func (q *SelectQuery) Count(ctx context.Context) (int, error)

func (*SelectQuery) Distinct

func (q *SelectQuery) Distinct() *SelectQuery

func (*SelectQuery) DistinctOn

func (q *SelectQuery) DistinctOn(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) Err added in v1.1.10

func (q *SelectQuery) Err(err error) *SelectQuery

func (*SelectQuery) Except

func (q *SelectQuery) Except(other *SelectQuery) *SelectQuery

func (*SelectQuery) ExceptAll

func (q *SelectQuery) ExceptAll(other *SelectQuery) *SelectQuery

func (*SelectQuery) ExcludeColumn

func (q *SelectQuery) ExcludeColumn(columns ...string) *SelectQuery

func (*SelectQuery) Exec

func (q *SelectQuery) Exec(ctx context.Context, dest ...interface{}) (res sql.Result, err error)

func (*SelectQuery) Exists added in v1.0.7

func (q *SelectQuery) Exists(ctx context.Context) (bool, error)

func (*SelectQuery) For

func (q *SelectQuery) For(s string, args ...interface{}) *SelectQuery

func (*SelectQuery) ForceIndex added in v1.1.6

func (q *SelectQuery) ForceIndex(indexes ...string) *SelectQuery

func (*SelectQuery) ForceIndexForGroupBy added in v1.1.6

func (q *SelectQuery) ForceIndexForGroupBy(indexes ...string) *SelectQuery

func (*SelectQuery) ForceIndexForJoin added in v1.1.6

func (q *SelectQuery) ForceIndexForJoin(indexes ...string) *SelectQuery

func (*SelectQuery) ForceIndexForOrderBy added in v1.1.6

func (q *SelectQuery) ForceIndexForOrderBy(indexes ...string) *SelectQuery

func (*SelectQuery) Group

func (q *SelectQuery) Group(columns ...string) *SelectQuery

func (*SelectQuery) GroupExpr

func (q *SelectQuery) GroupExpr(group string, args ...interface{}) *SelectQuery

func (*SelectQuery) Having

func (q *SelectQuery) Having(having string, args ...interface{}) *SelectQuery

func (*SelectQuery) IgnoreIndex added in v1.1.6

func (q *SelectQuery) IgnoreIndex(indexes ...string) *SelectQuery

func (*SelectQuery) IgnoreIndexForGroupBy added in v1.1.6

func (q *SelectQuery) IgnoreIndexForGroupBy(indexes ...string) *SelectQuery

func (*SelectQuery) IgnoreIndexForJoin added in v1.1.6

func (q *SelectQuery) IgnoreIndexForJoin(indexes ...string) *SelectQuery

func (*SelectQuery) IgnoreIndexForOrderBy added in v1.1.6

func (q *SelectQuery) IgnoreIndexForOrderBy(indexes ...string) *SelectQuery

func (*SelectQuery) Intersect

func (q *SelectQuery) Intersect(other *SelectQuery) *SelectQuery

func (*SelectQuery) IntersectAll

func (q *SelectQuery) IntersectAll(other *SelectQuery) *SelectQuery

func (*SelectQuery) Join

func (q *SelectQuery) Join(join string, args ...interface{}) *SelectQuery

func (*SelectQuery) JoinOn

func (q *SelectQuery) JoinOn(cond string, args ...interface{}) *SelectQuery

func (*SelectQuery) JoinOnOr

func (q *SelectQuery) JoinOnOr(cond string, args ...interface{}) *SelectQuery

func (*SelectQuery) Limit

func (q *SelectQuery) Limit(n int) *SelectQuery

func (*SelectQuery) Model

func (q *SelectQuery) Model(model interface{}) *SelectQuery

func (*SelectQuery) ModelTableExpr

func (q *SelectQuery) ModelTableExpr(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) Offset

func (q *SelectQuery) Offset(n int) *SelectQuery

func (*SelectQuery) Operation added in v1.0.5

func (q *SelectQuery) Operation() string

func (*SelectQuery) Order

func (q *SelectQuery) Order(orders ...string) *SelectQuery

func (*SelectQuery) OrderExpr

func (q *SelectQuery) OrderExpr(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) QueryBuilder added in v1.1.4

func (q *SelectQuery) QueryBuilder() QueryBuilder

func (*SelectQuery) Relation

func (q *SelectQuery) Relation(name string, apply ...func(*SelectQuery) *SelectQuery) *SelectQuery

Relation adds a relation to the query.

func (*SelectQuery) Rows

func (q *SelectQuery) Rows(ctx context.Context) (*sql.Rows, error)

func (*SelectQuery) Scan

func (q *SelectQuery) Scan(ctx context.Context, dest ...interface{}) error

func (*SelectQuery) ScanAndCount

func (q *SelectQuery) ScanAndCount(ctx context.Context, dest ...interface{}) (int, error)

func (*SelectQuery) String added in v1.1.6

func (q *SelectQuery) String() string

func (*SelectQuery) Table

func (q *SelectQuery) Table(tables ...string) *SelectQuery

func (*SelectQuery) TableExpr

func (q *SelectQuery) TableExpr(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) Union

func (q *SelectQuery) Union(other *SelectQuery) *SelectQuery

func (*SelectQuery) UnionAll

func (q *SelectQuery) UnionAll(other *SelectQuery) *SelectQuery

func (*SelectQuery) UseIndex added in v1.1.6

func (q *SelectQuery) UseIndex(indexes ...string) *SelectQuery

func (*SelectQuery) UseIndexForGroupBy added in v1.1.6

func (q *SelectQuery) UseIndexForGroupBy(indexes ...string) *SelectQuery

func (*SelectQuery) UseIndexForJoin added in v1.1.6

func (q *SelectQuery) UseIndexForJoin(indexes ...string) *SelectQuery

func (*SelectQuery) UseIndexForOrderBy added in v1.1.6

func (q *SelectQuery) UseIndexForOrderBy(indexes ...string) *SelectQuery

func (*SelectQuery) Where

func (q *SelectQuery) Where(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) WhereAllWithDeleted

func (q *SelectQuery) WhereAllWithDeleted() *SelectQuery

func (*SelectQuery) WhereDeleted

func (q *SelectQuery) WhereDeleted() *SelectQuery

func (*SelectQuery) WhereGroup

func (q *SelectQuery) WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery

func (*SelectQuery) WhereOr

func (q *SelectQuery) WhereOr(query string, args ...interface{}) *SelectQuery

func (*SelectQuery) WherePK

func (q *SelectQuery) WherePK(cols ...string) *SelectQuery

func (*SelectQuery) With

func (q *SelectQuery) With(name string, query schema.QueryAppender) *SelectQuery

func (*SelectQuery) WithRecursive added in v1.1.9

func (q *SelectQuery) WithRecursive(name string, query schema.QueryAppender) *SelectQuery

type Stmt

type Stmt struct {
	*sql.Stmt
}

type TableModel added in v1.0.9

type TableModel interface {
	Model

	schema.BeforeAppendModelHook
	schema.BeforeScanRowHook
	schema.AfterScanRowHook
	ScanColumn(column string, src interface{}) error

	Table() *schema.Table
	Relation() *schema.Relation
	// contains filtered or unexported methods
}

type TruncateTableQuery

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

func NewTruncateTableQuery

func NewTruncateTableQuery(db *DB) *TruncateTableQuery

func (*TruncateTableQuery) AppendNamedArg added in v0.4.0

func (q *TruncateTableQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*TruncateTableQuery) AppendQuery

func (q *TruncateTableQuery) AppendQuery(
	fmter schema.Formatter, b []byte,
) (_ []byte, err error)

func (*TruncateTableQuery) Cascade added in v1.0.20

func (q *TruncateTableQuery) Cascade() *TruncateTableQuery

func (*TruncateTableQuery) Conn added in v0.1.14

func (*TruncateTableQuery) ContinueIdentity

func (q *TruncateTableQuery) ContinueIdentity() *TruncateTableQuery

func (*TruncateTableQuery) DB

func (q *TruncateTableQuery) DB() *DB

func (*TruncateTableQuery) Dialect added in v1.0.21

func (q *TruncateTableQuery) Dialect() schema.Dialect

func (*TruncateTableQuery) Err added in v1.1.10

func (*TruncateTableQuery) Exec

func (q *TruncateTableQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*TruncateTableQuery) GetConn added in v1.0.21

func (q *TruncateTableQuery) GetConn() IConn

func (*TruncateTableQuery) GetModel added in v0.2.0

func (q *TruncateTableQuery) GetModel() Model

func (*TruncateTableQuery) GetTableName added in v1.0.9

func (q *TruncateTableQuery) GetTableName() string

func (*TruncateTableQuery) Model

func (q *TruncateTableQuery) Model(model interface{}) *TruncateTableQuery

func (*TruncateTableQuery) NewAddColumn added in v1.0.21

func (q *TruncateTableQuery) NewAddColumn() *AddColumnQuery

func (*TruncateTableQuery) NewCreateIndex added in v1.0.21

func (q *TruncateTableQuery) NewCreateIndex() *CreateIndexQuery

func (*TruncateTableQuery) NewCreateTable added in v1.0.21

func (q *TruncateTableQuery) NewCreateTable() *CreateTableQuery

func (*TruncateTableQuery) NewDelete added in v1.0.21

func (q *TruncateTableQuery) NewDelete() *DeleteQuery

func (*TruncateTableQuery) NewDropColumn added in v1.0.21

func (q *TruncateTableQuery) NewDropColumn() *DropColumnQuery

func (*TruncateTableQuery) NewDropIndex added in v1.0.21

func (q *TruncateTableQuery) NewDropIndex() *DropIndexQuery

func (*TruncateTableQuery) NewDropTable added in v1.0.21

func (q *TruncateTableQuery) NewDropTable() *DropTableQuery

func (*TruncateTableQuery) NewInsert added in v1.0.21

func (q *TruncateTableQuery) NewInsert() *InsertQuery

func (*TruncateTableQuery) NewRaw added in v1.1.8

func (q *TruncateTableQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*TruncateTableQuery) NewSelect added in v1.0.21

func (q *TruncateTableQuery) NewSelect() *SelectQuery

func (*TruncateTableQuery) NewTruncateTable added in v1.0.21

func (q *TruncateTableQuery) NewTruncateTable() *TruncateTableQuery

func (*TruncateTableQuery) NewUpdate added in v1.0.21

func (q *TruncateTableQuery) NewUpdate() *UpdateQuery

func (*TruncateTableQuery) NewValues added in v1.0.21

func (q *TruncateTableQuery) NewValues(model interface{}) *ValuesQuery

func (*TruncateTableQuery) Operation added in v1.0.5

func (q *TruncateTableQuery) Operation() string

func (*TruncateTableQuery) Restrict

func (q *TruncateTableQuery) Restrict() *TruncateTableQuery

func (*TruncateTableQuery) Table

func (q *TruncateTableQuery) Table(tables ...string) *TruncateTableQuery

func (*TruncateTableQuery) TableExpr

func (q *TruncateTableQuery) TableExpr(query string, args ...interface{}) *TruncateTableQuery

type Tx

type Tx struct {
	*sql.Tx
	// contains filtered or unexported fields
}

func (Tx) Begin added in v1.1.6

func (tx Tx) Begin() (Tx, error)

func (Tx) BeginTx added in v1.1.6

func (tx Tx) BeginTx(ctx context.Context, _ *sql.TxOptions) (Tx, error)

BeginTx will save a point in the running transaction.

func (Tx) Commit added in v1.0.16

func (tx Tx) Commit() error

func (Tx) Dialect added in v1.0.20

func (tx Tx) Dialect() schema.Dialect

func (Tx) Exec added in v0.1.3

func (tx Tx) Exec(query string, args ...interface{}) (sql.Result, error)

func (Tx) ExecContext added in v0.1.3

func (tx Tx) ExecContext(
	ctx context.Context, query string, args ...interface{},
) (sql.Result, error)

func (Tx) NewAddColumn added in v0.1.12

func (tx Tx) NewAddColumn() *AddColumnQuery

func (Tx) NewCreateIndex added in v0.1.12

func (tx Tx) NewCreateIndex() *CreateIndexQuery

func (Tx) NewCreateTable added in v0.1.12

func (tx Tx) NewCreateTable() *CreateTableQuery

func (Tx) NewDelete added in v0.1.12

func (tx Tx) NewDelete() *DeleteQuery

func (Tx) NewDropColumn added in v0.1.12

func (tx Tx) NewDropColumn() *DropColumnQuery

func (Tx) NewDropIndex added in v0.1.12

func (tx Tx) NewDropIndex() *DropIndexQuery

func (Tx) NewDropTable added in v0.1.12

func (tx Tx) NewDropTable() *DropTableQuery

func (Tx) NewInsert added in v0.1.12

func (tx Tx) NewInsert() *InsertQuery

func (Tx) NewMerge added in v1.1.10

func (tx Tx) NewMerge() *MergeQuery

func (Tx) NewRaw added in v1.1.8

func (tx Tx) NewRaw(query string, args ...interface{}) *RawQuery

func (Tx) NewSelect added in v0.1.12

func (tx Tx) NewSelect() *SelectQuery

func (Tx) NewTruncateTable added in v0.1.12

func (tx Tx) NewTruncateTable() *TruncateTableQuery

func (Tx) NewUpdate added in v0.1.12

func (tx Tx) NewUpdate() *UpdateQuery

func (Tx) NewValues added in v0.1.12

func (tx Tx) NewValues(model interface{}) *ValuesQuery

func (Tx) Query added in v0.1.3

func (tx Tx) Query(query string, args ...interface{}) (*sql.Rows, error)

func (Tx) QueryContext added in v0.1.3

func (tx Tx) QueryContext(
	ctx context.Context, query string, args ...interface{},
) (*sql.Rows, error)

func (Tx) QueryRow added in v0.1.3

func (tx Tx) QueryRow(query string, args ...interface{}) *sql.Row

func (Tx) QueryRowContext added in v0.1.3

func (tx Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (Tx) Rollback added in v1.0.16

func (tx Tx) Rollback() error

func (Tx) RunInTx added in v1.1.6

func (tx Tx) RunInTx(
	ctx context.Context, _ *sql.TxOptions, fn func(ctx context.Context, tx Tx) error,
) error

type UpdateQuery

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

func NewUpdateQuery

func NewUpdateQuery(db *DB) *UpdateQuery

func (*UpdateQuery) AppendQuery

func (q *UpdateQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*UpdateQuery) Apply

func (q *UpdateQuery) Apply(fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery

Apply calls the fn passing the SelectQuery as an argument.

func (*UpdateQuery) ApplyQueryBuilder added in v1.1.4

func (q *UpdateQuery) ApplyQueryBuilder(fn func(QueryBuilder) QueryBuilder) *UpdateQuery

func (*UpdateQuery) Bulk added in v0.2.8

func (q *UpdateQuery) Bulk() *UpdateQuery

func (*UpdateQuery) Column

func (q *UpdateQuery) Column(columns ...string) *UpdateQuery

func (*UpdateQuery) Conn added in v0.1.14

func (q *UpdateQuery) Conn(db IConn) *UpdateQuery

func (*UpdateQuery) Err added in v1.1.10

func (q *UpdateQuery) Err(err error) *UpdateQuery

func (*UpdateQuery) ExcludeColumn added in v0.2.0

func (q *UpdateQuery) ExcludeColumn(columns ...string) *UpdateQuery

func (*UpdateQuery) Exec

func (q *UpdateQuery) Exec(ctx context.Context, dest ...interface{}) (sql.Result, error)

func (*UpdateQuery) FQN added in v0.1.3

func (q *UpdateQuery) FQN(column string) Ident

FQN returns a fully qualified column name, for example, table_name.column_name or table_alias.column_alias.

func (*UpdateQuery) ForceIndex added in v1.1.6

func (q *UpdateQuery) ForceIndex(indexes ...string) *UpdateQuery

func (*UpdateQuery) IgnoreIndex added in v1.1.6

func (q *UpdateQuery) IgnoreIndex(indexes ...string) *UpdateQuery

func (*UpdateQuery) Model

func (q *UpdateQuery) Model(model interface{}) *UpdateQuery

func (*UpdateQuery) ModelTableExpr

func (q *UpdateQuery) ModelTableExpr(query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) OmitZero added in v1.0.10

func (q *UpdateQuery) OmitZero() *UpdateQuery

func (*UpdateQuery) Operation added in v1.0.5

func (q *UpdateQuery) Operation() string

func (*UpdateQuery) QueryBuilder added in v1.1.4

func (q *UpdateQuery) QueryBuilder() QueryBuilder

func (*UpdateQuery) Returning

func (q *UpdateQuery) Returning(query string, args ...interface{}) *UpdateQuery

Returning adds a RETURNING clause to the query.

To suppress the auto-generated RETURNING clause, use `Returning("NULL")`.

func (*UpdateQuery) Scan added in v1.1.10

func (q *UpdateQuery) Scan(ctx context.Context, dest ...interface{}) error

func (*UpdateQuery) Set

func (q *UpdateQuery) Set(query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) SetColumn added in v1.1.0

func (q *UpdateQuery) SetColumn(column string, query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) String added in v1.1.6

func (q *UpdateQuery) String() string

func (*UpdateQuery) Table

func (q *UpdateQuery) Table(tables ...string) *UpdateQuery

func (*UpdateQuery) TableExpr

func (q *UpdateQuery) TableExpr(query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) UseIndex added in v1.1.6

func (q *UpdateQuery) UseIndex(indexes ...string) *UpdateQuery

func (*UpdateQuery) Value

func (q *UpdateQuery) Value(column string, query string, args ...interface{}) *UpdateQuery

Value overwrites model value for the column.

func (*UpdateQuery) Where

func (q *UpdateQuery) Where(query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) WhereAllWithDeleted

func (q *UpdateQuery) WhereAllWithDeleted() *UpdateQuery

func (*UpdateQuery) WhereDeleted

func (q *UpdateQuery) WhereDeleted() *UpdateQuery

func (*UpdateQuery) WhereGroup

func (q *UpdateQuery) WhereGroup(sep string, fn func(*UpdateQuery) *UpdateQuery) *UpdateQuery

func (*UpdateQuery) WhereOr

func (q *UpdateQuery) WhereOr(query string, args ...interface{}) *UpdateQuery

func (*UpdateQuery) WherePK

func (q *UpdateQuery) WherePK(cols ...string) *UpdateQuery

func (*UpdateQuery) With

func (q *UpdateQuery) With(name string, query schema.QueryAppender) *UpdateQuery

func (*UpdateQuery) WithRecursive added in v1.1.9

func (q *UpdateQuery) WithRecursive(name string, query schema.QueryAppender) *UpdateQuery

type ValuesQuery

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

func NewValuesQuery

func NewValuesQuery(db *DB, model interface{}) *ValuesQuery

func (*ValuesQuery) AppendColumns

func (q *ValuesQuery) AppendColumns(fmter schema.Formatter, b []byte) (_ []byte, err error)

AppendColumns appends the table columns. It is used by CTE.

func (*ValuesQuery) AppendNamedArg added in v0.4.0

func (q *ValuesQuery) AppendNamedArg(fmter schema.Formatter, b []byte, name string) ([]byte, bool)

func (*ValuesQuery) AppendQuery

func (q *ValuesQuery) AppendQuery(fmter schema.Formatter, b []byte) (_ []byte, err error)

func (*ValuesQuery) Column added in v1.0.22

func (q *ValuesQuery) Column(columns ...string) *ValuesQuery

func (*ValuesQuery) Conn added in v0.1.14

func (q *ValuesQuery) Conn(db IConn) *ValuesQuery

func (*ValuesQuery) DB

func (q *ValuesQuery) DB() *DB

func (*ValuesQuery) Dialect added in v1.0.21

func (q *ValuesQuery) Dialect() schema.Dialect

func (*ValuesQuery) Err added in v1.1.10

func (q *ValuesQuery) Err(err error) *ValuesQuery

func (*ValuesQuery) GetConn added in v1.0.21

func (q *ValuesQuery) GetConn() IConn

func (*ValuesQuery) GetModel added in v0.2.0

func (q *ValuesQuery) GetModel() Model

func (*ValuesQuery) GetTableName added in v1.0.9

func (q *ValuesQuery) GetTableName() string

func (*ValuesQuery) NewAddColumn added in v1.0.21

func (q *ValuesQuery) NewAddColumn() *AddColumnQuery

func (*ValuesQuery) NewCreateIndex added in v1.0.21

func (q *ValuesQuery) NewCreateIndex() *CreateIndexQuery

func (*ValuesQuery) NewCreateTable added in v1.0.21

func (q *ValuesQuery) NewCreateTable() *CreateTableQuery

func (*ValuesQuery) NewDelete added in v1.0.21

func (q *ValuesQuery) NewDelete() *DeleteQuery

func (*ValuesQuery) NewDropColumn added in v1.0.21

func (q *ValuesQuery) NewDropColumn() *DropColumnQuery

func (*ValuesQuery) NewDropIndex added in v1.0.21

func (q *ValuesQuery) NewDropIndex() *DropIndexQuery

func (*ValuesQuery) NewDropTable added in v1.0.21

func (q *ValuesQuery) NewDropTable() *DropTableQuery

func (*ValuesQuery) NewInsert added in v1.0.21

func (q *ValuesQuery) NewInsert() *InsertQuery

func (*ValuesQuery) NewRaw added in v1.1.8

func (q *ValuesQuery) NewRaw(query string, args ...interface{}) *RawQuery

func (*ValuesQuery) NewSelect added in v1.0.21

func (q *ValuesQuery) NewSelect() *SelectQuery

func (*ValuesQuery) NewTruncateTable added in v1.0.21

func (q *ValuesQuery) NewTruncateTable() *TruncateTableQuery

func (*ValuesQuery) NewUpdate added in v1.0.21

func (q *ValuesQuery) NewUpdate() *UpdateQuery

func (*ValuesQuery) NewValues added in v1.0.21

func (q *ValuesQuery) NewValues(model interface{}) *ValuesQuery

func (*ValuesQuery) Operation added in v1.0.5

func (q *ValuesQuery) Operation() string

func (*ValuesQuery) Value added in v1.0.1

func (q *ValuesQuery) Value(column string, expr string, args ...interface{}) *ValuesQuery

Value overwrites model value for the column.

func (*ValuesQuery) WithOrder

func (q *ValuesQuery) WithOrder() *ValuesQuery

Directories

Path Synopsis
dbfixture module
mssqldialect Module
mysqldialect Module
pgdialect Module
sqlitedialect Module
driver
pgdriver Module
sqliteshim Module
example
basic Module
belongs-to Module
fixture Module
has-many Module
has-one Module
migrate Module
model-hooks Module
opentelemetry Module
pg-listen Module
trivial Module
extra
bunbig Module
bundebug Module
bunotel Module
bunrelic Module
fixture module
testfixture module
dbtest Module

Jump to

Keyboard shortcuts

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