sqb

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 5 Imported by: 0

README

SQL Query Builder

Blazing fast, Flexible, SQL Query Builder for Go

GoDoc CircleCI codecov Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(left, right stmt.Expr, exprs ...stmt.Expr) *stmt.And

And creates statement for the AND boolean expression. If you want to know more details, See at stmt.And.

func AndFromMap

func AndFromMap(f ConditionalFunc, m map[string]interface{}) stmt.Expr

AndFromMap Creates a concatenated string of AND boolean expression from a map.

If there is no first argument then occurs panic. If map length is zero it returns nil. If map length is 1 it returns *stmt.Condition created by ConditionalFunc.

func Between

func Between(column string, left, right interface{}) *stmt.Condition

Between creates condition `column BETWEEN ? AND ?`.

func Eq

func Eq(column string, value interface{}) *stmt.Condition

Eq creates condition `column = ?`.

func Ge

func Ge(column string, value interface{}) *stmt.Condition

Ge creates condition `column >= ?`.

func Gt

func Gt(column string, value interface{}) *stmt.Condition

Gt creates condition `column > ?`.

func In

func In(column string, args ...interface{}) *stmt.Condition

In creates condition `column IN (?, ?, ?, ...)`.

func Le

func Le(column string, value interface{}) *stmt.Condition

Le creates condition `column <= ?`.

func Like

func Like(column string, value interface{}) *stmt.Condition

Like creates condition `column LIKE ?`.

func Lt

func Lt(column string, value interface{}) *stmt.Condition

Lt creates condition `column < ?`.

func Ne

func Ne(column string, value interface{}) *stmt.Condition

Ne creates condition `column != ?`.

func NotBetween

func NotBetween(column string, left, right interface{}) *stmt.Condition

NotBetween creates condition `column NOT BETWEEN ? AND ?`.

func NotIn

func NotIn(column string, args ...interface{}) *stmt.Condition

NotIn creates condition `column NOT IN (?, ?, ?, ...)`.

func NotLike

func NotLike(column string, value interface{}) *stmt.Condition

NotLike creates condition `column NOT LIKE ?`.

func Op

func Op(op, column string, value interface{}) *stmt.Condition

Op creates flexible compare operation.

func Or

func Or(left, right stmt.Expr, exprs ...stmt.Expr) *stmt.Or

Or creates statement for the OR boolean expression with parentheses. If you want to know more details, See at stmt.Or.

func OrFromMap

func OrFromMap(f ConditionalFunc, m map[string]interface{}) stmt.Expr

OrFromMap Creates a concatenated string of OR boolean expression from a map.

If there is no first argument then occurs panic. If map length is zero it returns nil. If map length is 1 it returns *stmt.Condition created by ConditionalFunc.

func Paren

func Paren(expr stmt.Expr) *stmt.Paren

Paren creates the expression with parentheses.

Types

type Builder

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

Builder builds sql query string.

func New

func New(sqlstr string) *Builder

New returns sql query builder.

func (*Builder) Bind

func (b *Builder) Bind(expr stmt.Expr) *Builder

Bind binds expression to bindVars. returns copied *Builder which bound expression.

func (*Builder) Build

func (b *Builder) Build() (string, []interface{}, error)

Build builds sql query string, returning the built query string and a new arg list that can be executed by a database. The `query` should use the `?` bindVar. The return value uses the `?` bindVar.

type ConditionalFunc

type ConditionalFunc func(column string, value interface{}) *stmt.Condition

ConditionalFunc indicates function of conditional.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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