Documentation
¶
Index ¶
- type Builder
- func (b *Builder) Args() []any
- func (b *Builder) Condition(expression string) *Builder
- func (b *Builder) Conditionf(format string, args ...any) *Builder
- func (b *Builder) Conditionp(lhs, op string, val any) *Builder
- func (b *Builder) Limit(limit int) *Builder
- func (b *Builder) Offset(offset int) *Builder
- func (b *Builder) OrderBy(column string, direction OrderDirection) *Builder
- func (b *Builder) Query() string
- func (b *Builder) SelectAll(table string, alias string) *Builder
- type OrderDirection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) Condition ¶
Condition adds a condition to the query. This function accepts a raw expression string. Special characters like '%' do not need to be escaped. Example: Condition("name = '@name'")
func (*Builder) Conditionf ¶
Conditionf adds a condition to the query. This function accepts a format string and arguments, which will be used to create the condition. If the condition uses special characters like '%', they need to be escaped like '%%'. Example: Conditionf("name = '%s'", "John")
func (*Builder) Conditionp ¶
Conditionp adds a condition to the query as a positional argument ('$1', '$2'...). lhs is the left-hand side of the condition, op is the operator and val is the value.
Example: Conditionp("name", "=", "John") will be added as "name = '$1'".
type OrderDirection ¶
type OrderDirection string
const ( OrderByAscending OrderDirection = "ASC" OrderByDescending OrderDirection = "DESC" )