Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPtr(b sql.NullBool) *bool
- func BytePtr(i sql.NullByte) *byte
- func DecimalPtr(d decimal.NullDecimal) *decimal.Decimal
- func Float64Ptr(f sql.NullFloat64) *float64
- func Int16Ptr(i sql.NullInt16) *int16
- func Int32Ptr(i sql.NullInt32) *int32
- func Int64Ptr(i sql.NullInt64) *int64
- func NullBool(b bool) sql.NullBool
- func NullBoolPtr(b *bool) sql.NullBool
- func NullBoolValid(b bool) sql.NullBool
- func NullByte(b byte) sql.NullByte
- func NullBytePtr(b *byte) sql.NullByte
- func NullByteValid(b byte) sql.NullByte
- func NullDecimal(d decimal.Decimal) decimal.NullDecimal
- func NullDecimalPtr(d *decimal.Decimal) decimal.NullDecimal
- func NullDecimalValid(d decimal.Decimal) decimal.NullDecimal
- func NullFloat64(f float64) sql.NullFloat64
- func NullFloat64Ptr(f *float64) sql.NullFloat64
- func NullFloat64Valid(f float64) sql.NullFloat64
- func NullInt16(i int16) sql.NullInt16
- func NullInt16Ptr(i *int16) sql.NullInt16
- func NullInt16Valid(i int16) sql.NullInt16
- func NullInt32(i int32) sql.NullInt32
- func NullInt32Ptr(i *int32) sql.NullInt32
- func NullInt32Valid(i int32) sql.NullInt32
- func NullInt64(i int64) sql.NullInt64
- func NullInt64Ptr(i *int64) sql.NullInt64
- func NullInt64Valid(i int64) sql.NullInt64
- func NullString(s string) sql.NullString
- func NullStringPtr(s *string) sql.NullString
- func NullStringValid(s string) sql.NullString
- func NullTime(t time.Time) sql.NullTime
- func NullTimePtr(t *time.Time) sql.NullTime
- func NullTimeValid(t time.Time) sql.NullTime
- func StringPtr(s sql.NullString) *string
- func TimePtr(t sql.NullTime) *time.Time
- type Builder
- func (b Builder) Clauses(clauses ...Clause) Builder
- func (b Builder) Columns(columns ...string) Builder
- func (b Builder) Command(command string) Builder
- func (b Builder) Delete() Builder
- func (b Builder) Distinct() Builder
- func (b Builder) Exec() (sql.Result, error)
- func (b Builder) ExecContext(ctx context.Context) (sql.Result, error)
- func (b Builder) ExecRaw(query string, args ...any) (sql.Result, error)
- func (b Builder) From(table string) Builder
- func (b Builder) FromSelect(from Expr, alias string) Builder
- func (b Builder) Get(dest any) error
- func (b Builder) GetAll(dest any) error
- func (b Builder) GetAllContext(ctx context.Context, dest any) error
- func (b Builder) GetContext(ctx context.Context, dest any) error
- func (b Builder) GroupBy(groupBys ...string) Builder
- func (b Builder) Having(rawSQL string, args ...any) Builder
- func (b Builder) Insert() Builder
- func (b Builder) InsertReturning() error
- func (b Builder) InsertReturningContext(ctx context.Context) error
- func (b Builder) Into(table string) Builder
- func (b Builder) Join(joinType, join string, args ...any) Builder
- func (b Builder) JoinExpr(expr ...JoinExpr) Builder
- func (b Builder) JoinRaw(rawSQL string, args ...any) Builder
- func (b Builder) Limit(limit int64) Builder
- func (b Builder) LimitOffset(limit, offset int64) Builder
- func (b Builder) New() Builder
- func (b Builder) Offset(offset int64) Builder
- func (b Builder) Options(options ...string) Builder
- func (b Builder) OrderBy(orderBys ...string) Builder
- func (b Builder) OrderByArgs(rawSQL string, args ...any) Builder
- func (b Builder) PlaceholderFormat(placeholderFormat PlaceholderFormat) Builder
- func (b Builder) Prefix(rawSQL string, args ...any) Builder
- func (b Builder) Query() (*sql.Rows, error)
- func (b Builder) QueryContext(ctx context.Context) (*sql.Rows, error)
- func (b Builder) QueryRow() (*sql.Row, error)
- func (b Builder) QueryRowContext(ctx context.Context) (*sql.Row, error)
- func (b Builder) Raw(ctx context.Context, dest any, query string, args ...any) error
- func (b Builder) RunInTransaction(ctx context.Context, exec func(Builder) error) error
- func (b Builder) Select(columns ...string) Builder
- func (b Builder) SelectColumn(rawSQL string, args ...any) Builder
- func (b Builder) SelectColumns(columns ...string) Builder
- func (b Builder) Set(column string, value any) Builder
- func (b Builder) SetExpr(expr ...Expr) Builder
- func (b Builder) SetMap(clauses map[string]any) Builder
- func (b Builder) StructColumns(object any, columns ...string) Builder
- func (b Builder) Suffix(rawSQL string, args ...any) Builder
- func (b Builder) Table(table string) Builder
- func (b Builder) ToQueryWithArgs() (string, []any, error)
- func (b Builder) ToSQL() (string, []any, error)
- func (b Builder) Update() Builder
- func (b Builder) Values(values ...any) Builder
- func (b Builder) Where(rawSQL string, args ...any) Builder
- func (b Builder) WhereExpr(expr ...Expr) Builder
- type Clause
- func Columns(columns ...string) Clause
- func Delete() Clause
- func Distinct() Clause
- func From(table string) Clause
- func FromSelect(from Expr, alias string) Clause
- func GroupBy(groupBys ...string) Clause
- func Having(rawSQL string, args ...any) Clause
- func Insert() Clause
- func Join(joinType, join string, args ...any) Clause
- func JoinBuilder(joinExpr ...JoinExpr) Clause
- func JoinRaw(rawSQL string, args ...any) Clause
- func Limit(limit int64) Clause
- func LimitOffset(limit, offset int64) Clause
- func Offset(offset int64) Clause
- func Options(options ...string) Clause
- func OrderBy(orderBy ...string) Clause
- func OrderByArgs(rawSQL string, args ...any) Clause
- func Prefix(rawSQL string, args ...any) Clause
- func Select(columns ...string) Clause
- func SelectColumn(rawSQL string, args ...any) Clause
- func SelectColumns(columns ...string) Clause
- func Set(column string, value any) Clause
- func SetExpr(expr ...Expr) Clause
- func Suffix(rawSQL string, args ...any) Clause
- func Update() Clause
- func Where(rawSQL string, args ...any) Clause
- func WhereExpr(expr ...Expr) Clause
- type Column
- type Connection
- type DB
- type Expr
- type JoinExpr
- type PlaceholderFormat
- type Table
- type Tx
- type Value
Constants ¶
View Source
const ( CommandSelect = "SELECT" CommandInsert = "INSERT" CommandUpdate = "UPDATE" CommandDelete = "DELETE" JoinInner = "INNER" JoinLeft = "LEFT" JoinRight = "RIGHT" JoinFull = "FULL" ColumnCreatedAt = "created_at" ColumnUpdatedAt = "updated_at" )
Variables ¶
View Source
var ( SqlDBNotSet = errors.New("cannot run; no sql db set") ErrAlreadyInTransaction = errors.New("already in transaction") NotSetColumns = errors.New("columns must have at least one set of values") NotSetValues = errors.New("values must have at least one set of values") )
View Source
var ( // Dollar is a PlaceholderFormat instance that replaces placeholders with // dollar-prefixed positional placeholders (e.g. $1, $2, $3). Dollar = stringPlaceholderFormat("$") // Colon is a PlaceholderFormat instance that replaces placeholders with // colon-prefixed positional placeholders (e.g. :1, :2, :3). Colon = stringPlaceholderFormat(":") // AtP is a PlaceholderFormat instance that replaces placeholders with // "@p"-prefixed positional placeholders (e.g. @p1, @p2, @p3). AtP = stringPlaceholderFormat("@p") )
View Source
var DebugMode = false
Functions ¶
func DecimalPtr ¶
func DecimalPtr(d decimal.NullDecimal) *decimal.Decimal
func Float64Ptr ¶
func Float64Ptr(f sql.NullFloat64) *float64
func NullBoolPtr ¶
func NullBoolValid ¶
func NullBytePtr ¶
func NullByteValid ¶
func NullDecimal ¶
func NullDecimal(d decimal.Decimal) decimal.NullDecimal
func NullDecimalPtr ¶
func NullDecimalPtr(d *decimal.Decimal) decimal.NullDecimal
func NullDecimalValid ¶
func NullDecimalValid(d decimal.Decimal) decimal.NullDecimal
func NullFloat64 ¶
func NullFloat64(f float64) sql.NullFloat64
func NullFloat64Ptr ¶
func NullFloat64Ptr(f *float64) sql.NullFloat64
func NullFloat64Valid ¶
func NullFloat64Valid(f float64) sql.NullFloat64
func NullInt16Ptr ¶
func NullInt16Valid ¶
func NullInt32Ptr ¶
func NullInt32Valid ¶
func NullInt64Ptr ¶
func NullInt64Valid ¶
func NullString ¶
func NullString(s string) sql.NullString
func NullStringPtr ¶
func NullStringPtr(s *string) sql.NullString
func NullStringValid ¶
func NullStringValid(s string) sql.NullString
func StringPtr ¶
func StringPtr(s sql.NullString) *string
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilderTx ¶
func NewBuilderWriterReader ¶
func NewEmptyBuilder ¶
func NewEmptyBuilder() Builder
NewEmptyBuilder create empty builder only for ToSQL()
func (Builder) InsertReturning ¶
func (Builder) InsertReturningContext ¶
func (Builder) LimitOffset ¶
func (Builder) PlaceholderFormat ¶
func (b Builder) PlaceholderFormat(placeholderFormat PlaceholderFormat) Builder
func (Builder) QueryRowContext ¶
func (Builder) RunInTransaction ¶
func (Builder) SelectColumns ¶
func (Builder) StructColumns ¶
StructColumns set columns for update or insert from struct with db tags
type Clause ¶
func FromSelect ¶
func JoinBuilder ¶
func LimitOffset ¶
func OrderByArgs ¶
func SelectColumn ¶
func SelectColumns ¶
type Column ¶
type Column[T comparable] struct { Name string Set Value[T] EQ Value[T] NEQ Value[T] LT Value[T] LTE Value[T] GT Value[T] GTE Value[T] Like Value[T] NotLike Value[T] }
func NewColumn ¶
func NewColumn[T comparable](name string) Column[T]
func (Column[T]) IsNotNullValue ¶
func (Column[T]) IsNullValue ¶
type Connection ¶
type Connection interface { Rebind(sql string) string Get(dest any, query string, args ...any) error GetContext(ctx context.Context, dest any, query string, args ...any) error Select(dest any, query string, args ...any) error SelectContext(ctx context.Context, dest any, query string, args ...any) error Exec(query string, args ...any) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Query(query string, args ...any) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRow(query string, args ...any) *sql.Row QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row BeginTx(ctx context.Context) (*sqlx.Tx, error) }
func NewDB ¶
func NewDB(db *sqlx.DB) Connection
func NewTx ¶
func NewTx(tx *sqlx.Tx) Connection
type JoinExpr ¶
type JoinExpr interface { Expr SelectColumns() []string NewJoin(joinType string, table Table, alias, field, relatedField string) JoinExpr Alias() string RelatedTable(relatedTable string) JoinExpr }
func NewJoinBuilder ¶
type PlaceholderFormat ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (Table) ColumnsAlias ¶
func (Table) ColumnsTable ¶
Click to show internal directories.
Click to hide internal directories.