Documentation
¶
Index ¶
- func Now() driver.Valuer
- type Builder
- func (b *Builder) BulkInsert(table string, columns []string) *BulkInsert
- func (b *Builder) BulkUpsert(table string, columns []string, conflictColumn []string) *BulkInsert
- func (b *Builder) Delete(table string, where Where) *Delete
- func (b *Builder) Insert(table string) *InsertUpdate
- func (b *Builder) Select(fields, table string, args ...any) *Select
- func (b *Builder) Update(table string, where Where) *InsertUpdate
- func (b *Builder) Upsert(table string, conflictColumn ...string) *InsertUpdate
- type BulkInsert
- type Delete
- type Dialect
- type InsertUpdate
- func (i *InsertUpdate) Add(key string, value any) *InsertUpdate
- func (i *InsertUpdate) AddSelect(key string, s *Select) *InsertUpdate
- func (i *InsertUpdate) Clauses() map[string]any
- func (i *InsertUpdate) HasClauses() bool
- func (i *InsertUpdate) Returning(field string) *InsertUpdate
- func (i *InsertUpdate) Select(s *Select) *InsertUpdate
- func (i *InsertUpdate) ToSQL() (string, []any)
- func (i *InsertUpdate) With(obj any, opts ...WithOpt) *InsertUpdate
- type InsertUpdateOptions
- type Join
- type MySQLDialect
- type Options
- type PostgreSQLDialect
- type Select
- func (s *Select) GroupBy(field string) *Select
- func (s *Select) Having(where Where) *Select
- func (s *Select) Join(table string, on Where) *Select
- func (s *Select) LeftJoin(table string, on Where) *Select
- func (s *Select) Limit(limit int64) *Select
- func (s *Select) Offset(offset int64) *Select
- func (s *Select) OrderBy(fields ...string) *Select
- func (s *Select) OrderByDesc(field string) *Select
- func (s *Select) OrderByDir(field string, desc bool) *Select
- func (s *Select) ToSQL() (string, []any)
- func (s *Select) Union(o *Select) *Select
- func (s *Select) Where(where Where) *Select
- func (s *Select) With(o With) *Select
- type SqliteDialect
- type Where
- func All() Where
- func And(w ...Where) Where
- func Any(subQuery *Select) Where
- func ArrayOverlaps(field string, subQuery *Select) Where
- func Exists(subQuery *Select) Where
- func Expr(expr string, args ...any) Where
- func FieldEquals(field string, value any) Where
- func FieldGreaterOrEqualThan(field string, value any) Where
- func FieldGreaterThan(field string, value any) Where
- func FieldILike(field string, value any) Where
- func FieldIn(field string, values []any) Where
- func FieldLessOrEqualThan(field string, value any) Where
- func FieldLessThan(field string, value any) Where
- func FieldLike(field string, value any) Where
- func FieldNotEquals(field string, value any) Where
- func FieldNotIn(field string, values []any) Where
- func FieldOp(field, op string, value any) Where
- func IDEquals(v any) Where
- func IDIn(values []any) Where
- func In(field string, subQuery *Select) Where
- func IntFieldIn[T ~int64 | ~int32 | ~int](field string, values []T) Where
- func IntFieldNotIn(field string, values []int64) Where
- func IsNotNull(field string) Where
- func IsNull(field string) Where
- func Or(w ...Where) Where
- func StringFieldIn(field string, values []string) Where
- func StringFieldNotIn(field string, values []string) Where
- type With
- type WithOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func (*Builder) BulkInsert ¶
func (b *Builder) BulkInsert(table string, columns []string) *BulkInsert
func (*Builder) BulkUpsert ¶
func (b *Builder) BulkUpsert(table string, columns []string, conflictColumn []string) *BulkInsert
func (*Builder) Delete ¶
Explicitly takes a WHERE, since you'll almost always do this.
You can always pass All() in case you want to truncate the table, but at least that way it's obvious.
func (*Builder) Insert ¶
func (b *Builder) Insert(table string) *InsertUpdate
type BulkInsert ¶
type BulkInsert struct { Table string Columns []string Dialect Dialect Values [][]any // contains filtered or unexported fields }
func (*BulkInsert) Add ¶
func (i *BulkInsert) Add(values ...any) error
func (*BulkInsert) Count ¶
func (i *BulkInsert) Count() int
func (*BulkInsert) ToSQL ¶
func (i *BulkInsert) ToSQL() (string, []any)
type Delete ¶
func (*Delete) SetDialect ¶
type Dialect ¶
type Dialect interface { Placeholder(idx int) string UseLastInsertId() bool MakeUpsert(table string, conflictColumn []string, fields []fieldValue, rows int) string }
func DialectFromString ¶
type InsertUpdate ¶
type InsertUpdate struct { Table string // contains filtered or unexported fields }
func (*InsertUpdate) Add ¶
func (i *InsertUpdate) Add(key string, value any) *InsertUpdate
func (*InsertUpdate) AddSelect ¶
func (i *InsertUpdate) AddSelect(key string, s *Select) *InsertUpdate
func (*InsertUpdate) Clauses ¶
func (i *InsertUpdate) Clauses() map[string]any
func (*InsertUpdate) HasClauses ¶
func (i *InsertUpdate) HasClauses() bool
func (*InsertUpdate) Returning ¶
func (i *InsertUpdate) Returning(field string) *InsertUpdate
func (*InsertUpdate) Select ¶
func (i *InsertUpdate) Select(s *Select) *InsertUpdate
func (*InsertUpdate) ToSQL ¶
func (i *InsertUpdate) ToSQL() (string, []any)
func (*InsertUpdate) With ¶
func (i *InsertUpdate) With(obj any, opts ...WithOpt) *InsertUpdate
type InsertUpdateOptions ¶
type MySQLDialect ¶
type MySQLDialect struct { }
Generates queries using question marks
func (MySQLDialect) MakeUpsert ¶
func (d MySQLDialect) MakeUpsert(table string, conflictColumn []string, fields []fieldValue, rows int) string
func (MySQLDialect) Placeholder ¶
func (d MySQLDialect) Placeholder(idx int) string
func (MySQLDialect) UseLastInsertId ¶
func (d MySQLDialect) UseLastInsertId() bool
type Options ¶
type PostgreSQLDialect ¶
type PostgreSQLDialect struct { }
Generates queries using numbered placeholders
func (PostgreSQLDialect) MakeUpsert ¶
func (d PostgreSQLDialect) MakeUpsert(table string, conflictColumn []string, fields []fieldValue, rows int) string
func (PostgreSQLDialect) Placeholder ¶
func (d PostgreSQLDialect) Placeholder(idx int) string
func (PostgreSQLDialect) UseLastInsertId ¶
func (d PostgreSQLDialect) UseLastInsertId() bool
type Select ¶
type Select struct { Dialect Dialect Fields string Table string Options Options Joins []Join Unions []*Select CTEs []With Args []any }
func (*Select) OrderByDesc ¶
type SqliteDialect ¶
type SqliteDialect struct { }
Generates queries using numbered placeholders
func (SqliteDialect) MakeUpsert ¶
func (d SqliteDialect) MakeUpsert(table string, conflictColumn []string, fields []fieldValue, rows int) string
func (SqliteDialect) Placeholder ¶
func (d SqliteDialect) Placeholder(idx int) string
func (SqliteDialect) UseLastInsertId ¶
func (d SqliteDialect) UseLastInsertId() bool
type Where ¶
type Where struct {
// contains filtered or unexported fields
}
func ArrayOverlaps ¶
func FieldEquals ¶
func FieldGreaterOrEqualThan ¶
func FieldGreaterThan ¶
func FieldILike ¶
func FieldLessOrEqualThan ¶
func FieldLessThan ¶
func FieldNotEquals ¶
func FieldNotIn ¶
func IntFieldNotIn ¶
func StringFieldIn ¶
func StringFieldNotIn ¶
type WithOpt ¶
type WithOpt func(o *InsertUpdateOptions)
func WithAutoIncrement ¶
func WithAutoIncrement() WithOpt
func WithReadOnly ¶
func WithReadOnly() WithOpt
Click to show internal directories.
Click to hide internal directories.