dbs

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 20 Imported by: 17

README

DBS

SQL Builder 工具, 不是 ORM。

帮助

在集成的过程中有遇到问题,欢迎加 QQ 群 564704807 讨论。

安装

$ go get github.com/smartwalle/dbs

开始

package main

import (
	"fmt"
	"github.com/smartwalle/dbs"
)

func main() {
	var sb = dbs.NewSelectBuilder()
	sb.Selects("u.id", "u.name", "u.age")
	sb.From("user", "AS u")
	sb.Where("u.id = ?", 1)
	sb.Limit(1)

	sqlStr, args, _ := sb.SQL()
	fmt.Println("sqlStr:", sqlStr)
	fmt.Println("args:", args)
}

上述代码会输出如下内容:

sql: SELECT u.id, u.name, u.age FROM user AS u WHERE u.id = ? LIMIT ?
args: [10 1]
执行 SQL

此处使用 MySQL 作为演示,需要准备好一个测试用数据库及 user 表,user 表结构如下:

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `human_id_uindex` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8

package main

import (
	"database/sql"
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/smartwalle/dbs"
)

func main() {
	var sb = dbs.NewSelectBuilder()
	sb.Selects("u.id", "u.name", "u.age")
	sb.From("user", "AS u")
	sb.Where("u.id = ?", 1)
	sb.Limit(1)

	db, err := sql.Open("mysql", "数据库连接信息")
	if err != nil {
		fmt.Println("连接数据库出错:", err)
		return
	}
	defer db.Close()

	var user *User
	if err := sb.Scan(db, &user); err != nil {
		fmt.Println("Query 出错:", err)
		return
	}

	if user != nil {
		fmt.Println(user.Id, user.Name, user.Age)
	}
}

type User struct {
	Id   int64  `sql:"id"`
	Name string `sql:"name"`
	Age  int    `sql:"age"`
}

运行上述代码,如果数据库中存在 id 为 1 的数据,则会正常输出相关的信息。

Select
var sb = dbs.NewSelectBuilder()
sb.Selects("u.id", "u.name AS username", "u.age")
sb.Select(dbs.Alias("b.amount", "user_amount"))
sb.From("user", "AS u")
sb.LeftJoin("bank", "AS b ON b.user_id = u.id")
sb.Where("u.id = ?", 1)
fmt.Println(sb.SQL())

执行 Select 语句:

db, err := sql.Open("mysql", "数据库连接信息")
var user *User
sb.Scan(db, &user)
Insert
var ib = dbs.NewInsertBuilder()
ib.Table("user")
ib.Columns("name", "age")
ib.Values("用户1", 18)
ib.Values("用户2", 20)
fmt.Println(ib.SQL())

执行 Insert 语句:

db, err := sql.Open("mysql", "数据库连接信息")
ib.Exec(db)
Update
var ub = dbs.NewUpdateBuilder()
ub.Table("user")
ub.SET("name", "新的名字")
ub.Where("id = ? ", 1)
ub.Limit(1)
fmt.Println(ub.SQL())

执行 Update 语句:

db, err := sql.Open("mysql", "数据库连接信息")
ub.Exec(db)
Delete
var rb = dbs.NewDeleteBuilder()
rb.Table("user")
rb.Where("id = ?", 1)
rb.Limit(1)
fmt.Println(rb.SQL())

执行 Delete 语句:

db, err := sql.Open("mysql", "数据库连接信息")
rb.Exec(db)

更多内容请参考 test 文件。

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DialectMySQL      = &mysql{}
	DialectDefault    = DialectMySQL
	DialectPostgreSQL = &postgresql{}
)

Functions

func AND

func AND(stmts ...Statement) *whereStmt

func Alias

func Alias(sql interface{}, alias string) *aliasStmt

func Case

func Case(what ...interface{}) *caseStmt

func Find

func Find(s Session, table string, dest interface{}, limit, offset int64, w Statement) (err error)

func FindAll

func FindAll(s Session, table string, dest interface{}, w Statement) (err error)

func FindOne

func FindOne(s Session, table string, dest interface{}, w Statement) (err error)

func GetFields

func GetFields(dest interface{}) (result []string, err error)

func MD5Key added in v1.2.0

func MD5Key(key string) string

func New added in v1.2.1

func New(driver, url string, maxOpen, maxIdle int) (db *sql.DB, err error)

func NewStatement

func NewStatement(sql interface{}, args ...interface{}) *statement

func Next added in v1.1.7

func Next() int64

func OR

func OR(stmts ...Statement) *whereStmt

func OnConflictKeyUpdate added in v1.1.7

func OnConflictKeyUpdate(columns ...string) *onConflictDoUpdateStmt

func OnDuplicateKeyUpdate

func OnDuplicateKeyUpdate() *onDuplicateKeyUpdateStmt

func SQL

func SQL(sql string, args ...interface{}) *statement

func Scan

func Scan(rows *sql.Rows, dest interface{}) (err error)

func SetLogger

func SetLogger(l Logger)

func UseDialect

func UseDialect(d Dialect)

func UseIdGenerator added in v1.1.7

func UseIdGenerator(g IdGenerator)

Types

type Buffer added in v1.0.3

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

func NewBuffer added in v1.0.1

func NewBuffer() *Buffer

func (*Buffer) Release added in v1.0.3

func (this *Buffer) Release()

func (*Buffer) Reset added in v1.0.3

func (this *Buffer) Reset()

func (*Buffer) String added in v1.0.3

func (this *Buffer) String() string

func (*Buffer) Values added in v1.0.3

func (this *Buffer) Values() []interface{}

func (*Buffer) Write added in v1.0.3

func (this *Buffer) Write(bs []byte) (int, error)

func (*Buffer) WriteArgs added in v1.0.3

func (this *Buffer) WriteArgs(args ...interface{})

func (*Buffer) WriteString added in v1.0.3

func (this *Buffer) WriteString(s string) (n int, err error)

type Builder

type Builder interface {
	Type() string
	SQL() (string, []interface{}, error)
}

type DB

type DB interface {
	Session

	Close() error

	Ping() error
	PingContext(ctx context.Context) error

	Begin() (*sql.Tx, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

type DBCache added in v1.0.6

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

func NewCache

func NewCache(db DB) *DBCache

func (*DBCache) Begin added in v1.0.6

func (this *DBCache) Begin() (*sql.Tx, error)

func (*DBCache) BeginTx added in v1.0.6

func (this *DBCache) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*DBCache) Close added in v1.0.6

func (this *DBCache) Close() error

func (*DBCache) Exec added in v1.0.6

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

func (*DBCache) ExecContext added in v1.0.6

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

func (*DBCache) Ping added in v1.0.6

func (this *DBCache) Ping() error

func (*DBCache) PingContext added in v1.0.6

func (this *DBCache) PingContext(ctx context.Context) error

func (*DBCache) Prepare added in v1.0.6

func (this *DBCache) Prepare(query string) (*sql.Stmt, error)

func (*DBCache) PrepareContext added in v1.0.6

func (this *DBCache) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (*DBCache) Query added in v1.0.6

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

func (*DBCache) QueryContext added in v1.0.6

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

type DeleteBuilder

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

func NewDeleteBuilder

func NewDeleteBuilder() *DeleteBuilder

func (*DeleteBuilder) Alias

func (this *DeleteBuilder) Alias(alias ...string) *DeleteBuilder

func (*DeleteBuilder) Exec

func (this *DeleteBuilder) Exec(s Session) (sql.Result, error)

func (*DeleteBuilder) ExecContext

func (this *DeleteBuilder) ExecContext(ctx context.Context, s Session) (result sql.Result, err error)

func (*DeleteBuilder) GetDialect added in v1.1.7

func (this *DeleteBuilder) GetDialect() Dialect

func (*DeleteBuilder) Join

func (this *DeleteBuilder) Join(join, table, suffix string, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) LeftJoin

func (this *DeleteBuilder) LeftJoin(table, suffix string, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) Limit

func (this *DeleteBuilder) Limit(limit int64) *DeleteBuilder

func (*DeleteBuilder) Offset

func (this *DeleteBuilder) Offset(offset int64) *DeleteBuilder

func (*DeleteBuilder) Options

func (this *DeleteBuilder) Options(options ...string) *DeleteBuilder

func (*DeleteBuilder) OrderBy

func (this *DeleteBuilder) OrderBy(sql ...string) *DeleteBuilder

func (*DeleteBuilder) Prefix

func (this *DeleteBuilder) Prefix(sql string, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) RightJoin

func (this *DeleteBuilder) RightJoin(table, suffix string, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) SQL added in v1.2.1

func (this *DeleteBuilder) SQL() (string, []interface{}, error)

func (*DeleteBuilder) Suffix

func (this *DeleteBuilder) Suffix(sql interface{}, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) Table

func (this *DeleteBuilder) Table(table string, args ...string) *DeleteBuilder

func (*DeleteBuilder) Type

func (this *DeleteBuilder) Type() string

func (*DeleteBuilder) USING

func (this *DeleteBuilder) USING(sql string) *DeleteBuilder

func (*DeleteBuilder) UseDialect

func (this *DeleteBuilder) UseDialect(d Dialect) *DeleteBuilder

func (*DeleteBuilder) Where

func (this *DeleteBuilder) Where(sql interface{}, args ...interface{}) *DeleteBuilder

func (*DeleteBuilder) Write added in v1.2.1

func (this *DeleteBuilder) Write(w Writer) (err error)

type Dialect added in v1.1.7

type Dialect interface {
	ParseVal(sql string) (string, error)
	Quote(s string) string
}

func GetDialect added in v1.1.7

func GetDialect() Dialect

type Eq

type Eq map[string]interface{}

func (Eq) SQL added in v1.2.1

func (this Eq) SQL() (string, []interface{}, error)

func (Eq) Write added in v1.2.1

func (this Eq) Write(w Writer) error

type IdGenerator added in v1.1.7

type IdGenerator interface {
	Next() int64
}

func GetIdGenerator added in v1.1.7

func GetIdGenerator() IdGenerator

type InsertBuilder

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

func Insert

func Insert(columns ...string) *InsertBuilder

func NewInsertBuilder

func NewInsertBuilder() *InsertBuilder

func (*InsertBuilder) Clone

func (this *InsertBuilder) Clone() *InsertBuilder

func (*InsertBuilder) Column

func (this *InsertBuilder) Column(column string) *InsertBuilder

func (*InsertBuilder) Columns

func (this *InsertBuilder) Columns(columns ...string) *InsertBuilder

func (*InsertBuilder) Exec

func (this *InsertBuilder) Exec(s Session) (sql.Result, error)

func (*InsertBuilder) ExecContext

func (this *InsertBuilder) ExecContext(ctx context.Context, s Session) (result sql.Result, err error)

func (*InsertBuilder) GetDialect added in v1.1.7

func (this *InsertBuilder) GetDialect() Dialect

func (*InsertBuilder) Options

func (this *InsertBuilder) Options(options ...string) *InsertBuilder

func (*InsertBuilder) Prefix

func (this *InsertBuilder) Prefix(sql string, args ...interface{}) *InsertBuilder

func (*InsertBuilder) SET

func (this *InsertBuilder) SET(column string, value interface{}) *InsertBuilder

func (*InsertBuilder) SQL added in v1.2.1

func (this *InsertBuilder) SQL() (string, []interface{}, error)

func (*InsertBuilder) Select

func (this *InsertBuilder) Select(sb *SelectBuilder) *InsertBuilder

func (*InsertBuilder) Suffix

func (this *InsertBuilder) Suffix(sql interface{}, args ...interface{}) *InsertBuilder

func (*InsertBuilder) Table

func (this *InsertBuilder) Table(table string) *InsertBuilder

func (*InsertBuilder) Type

func (this *InsertBuilder) Type() string

func (*InsertBuilder) UseDialect

func (this *InsertBuilder) UseDialect(d Dialect) *InsertBuilder

func (*InsertBuilder) Values

func (this *InsertBuilder) Values(values ...interface{}) *InsertBuilder

func (*InsertBuilder) Write added in v1.2.1

func (this *InsertBuilder) Write(w Writer) (err error)

type Logger

type Logger interface {
	SetPrefix(prefix string)
	Prefix() string
	Println(args ...interface{})
	Printf(format string, args ...interface{})
	Output(calldepth int, s string) error
}

type NotEq

type NotEq Eq

func (NotEq) SQL added in v1.2.1

func (this NotEq) SQL() (string, []interface{}, error)

func (NotEq) Write added in v1.2.1

func (this NotEq) Write(w Writer) error

type RawBuilder

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

RawBuilder 原始 SQL 语句构造器,不会自动添加任何的关键字,主要是为了便于 SQL 语句及参数的管理。

func NewBuilder

func NewBuilder(sql string, args ...interface{}) *RawBuilder

func (*RawBuilder) Append

func (this *RawBuilder) Append(sql string, args ...interface{}) *RawBuilder

func (*RawBuilder) Exec

func (this *RawBuilder) Exec(s Session) (sql.Result, error)

func (*RawBuilder) ExecContext

func (this *RawBuilder) ExecContext(ctx context.Context, s Session) (result sql.Result, err error)

func (*RawBuilder) Format

func (this *RawBuilder) Format(format string, args ...interface{}) *RawBuilder

func (*RawBuilder) GetDialect added in v1.1.7

func (this *RawBuilder) GetDialect() Dialect

func (*RawBuilder) Params

func (this *RawBuilder) Params(args ...interface{}) *RawBuilder

func (*RawBuilder) Query

func (this *RawBuilder) Query(s Session) (*sql.Rows, error)

func (*RawBuilder) QueryContext

func (this *RawBuilder) QueryContext(ctx context.Context, s Session) (*sql.Rows, error)

func (*RawBuilder) SQL added in v1.2.1

func (this *RawBuilder) SQL() (string, []interface{}, error)

func (*RawBuilder) Scan

func (this *RawBuilder) Scan(s Session, dest interface{}) (err error)

func (*RawBuilder) ScanContext

func (this *RawBuilder) ScanContext(ctx context.Context, s Session, dest interface{}) (err error)

func (*RawBuilder) ScanRow

func (this *RawBuilder) ScanRow(s Session, dest ...interface{}) (err error)

func (*RawBuilder) ScanRowContext

func (this *RawBuilder) ScanRowContext(ctx context.Context, s Session, dest ...interface{}) (err error)

func (*RawBuilder) Type

func (this *RawBuilder) Type() string

func (*RawBuilder) UseDialect

func (this *RawBuilder) UseDialect(d Dialect) *RawBuilder

func (*RawBuilder) Write added in v1.2.1

func (this *RawBuilder) Write(w Writer) error

type SQLValue

type SQLValue interface {
	SQLValue() string
}

type SelectBuilder

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

func NewSelectBuilder

func NewSelectBuilder() *SelectBuilder

func Select

func Select(columns ...string) *SelectBuilder

func (*SelectBuilder) Clone

func (this *SelectBuilder) Clone() *SelectBuilder

func (*SelectBuilder) Count

func (this *SelectBuilder) Count(args ...string) *SelectBuilder

func (*SelectBuilder) FoundRows

func (this *SelectBuilder) FoundRows(args ...string) *SelectBuilder

func (*SelectBuilder) From

func (this *SelectBuilder) From(table string, args ...string) *SelectBuilder

func (*SelectBuilder) FromStmt

func (this *SelectBuilder) FromStmt(stmt Statement) *SelectBuilder

func (*SelectBuilder) GetDialect added in v1.1.7

func (this *SelectBuilder) GetDialect() Dialect

func (*SelectBuilder) GroupBy

func (this *SelectBuilder) GroupBy(groupBys ...string) *SelectBuilder

func (*SelectBuilder) Having

func (this *SelectBuilder) Having(sql interface{}, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Join

func (this *SelectBuilder) Join(join, table, suffix string, args ...interface{}) *SelectBuilder

func (*SelectBuilder) LeftJoin

func (this *SelectBuilder) LeftJoin(table, suffix string, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Limit

func (this *SelectBuilder) Limit(limit int64) *SelectBuilder

func (*SelectBuilder) Offset

func (this *SelectBuilder) Offset(offset int64) *SelectBuilder

func (*SelectBuilder) Options

func (this *SelectBuilder) Options(options ...string) *SelectBuilder

func (*SelectBuilder) OrderBy

func (this *SelectBuilder) OrderBy(sql ...string) *SelectBuilder

func (*SelectBuilder) Prefix

func (this *SelectBuilder) Prefix(sql string, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Query

func (this *SelectBuilder) Query(s Session) (*sql.Rows, error)

func (*SelectBuilder) QueryContext

func (this *SelectBuilder) QueryContext(ctx context.Context, s Session) (*sql.Rows, error)

func (*SelectBuilder) RightJoin

func (this *SelectBuilder) RightJoin(table, suffix string, args ...interface{}) *SelectBuilder

func (*SelectBuilder) SQL added in v1.2.1

func (this *SelectBuilder) SQL() (string, []interface{}, error)

func (*SelectBuilder) Scan

func (this *SelectBuilder) Scan(s Session, dest interface{}) (err error)

Scan 读取数据到一个结构体中。 需要注意:声明变量的时候,变量应该为某一结构体的指针类型,不需要初始化,调用 Scan() 方法的时候,需要传递变量的地址。 var user *User

var sb = dbs.NewSelectBuilder() sb.Scan(db, &user)

func (*SelectBuilder) ScanContext

func (this *SelectBuilder) ScanContext(ctx context.Context, s Session, dest interface{}) (err error)

ScanContext 读取数据到一个结构体中。 需要注意:声明变量的时候,变量应该为某一结构体的指针类型,不需要初始化,调用 ScanContext() 方法的时候,需要传递变量的地址。 var user *User

var sb = dbs.NewSelectBuilder() sb.ScanContext(ctx, db, &user)

func (*SelectBuilder) ScanRow

func (this *SelectBuilder) ScanRow(s Session, dest ...interface{}) (err error)

ScanRow 读取数据到基本数据类型的变量中,类似于 database/sql 包中结构体 Rows 的 Scan() 方法。 var name string var age int

var sb = dbs.NewSelectBuilder() sb.ScanRow(db, &name, &age)

func (*SelectBuilder) ScanRowContext

func (this *SelectBuilder) ScanRowContext(ctx context.Context, s Session, dest ...interface{}) (err error)

ScanRowContext 读取数据到基本数据类型的变量中,类似于 database/sql 包中结构体 Rows 的 Scan() 方法。 var name string var age int

var sb = dbs.NewSelectBuilder() sb.ScanRowContext(ctx, db, &name, &age)

func (*SelectBuilder) Select

func (this *SelectBuilder) Select(column interface{}, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Selects

func (this *SelectBuilder) Selects(columns ...string) *SelectBuilder

func (*SelectBuilder) Suffix

func (this *SelectBuilder) Suffix(sql interface{}, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Type

func (this *SelectBuilder) Type() string

func (*SelectBuilder) UseDialect

func (this *SelectBuilder) UseDialect(d Dialect) *SelectBuilder

func (*SelectBuilder) UseSQLCalcFoundRows

func (this *SelectBuilder) UseSQLCalcFoundRows() *SelectBuilder

func (*SelectBuilder) Where

func (this *SelectBuilder) Where(sql interface{}, args ...interface{}) *SelectBuilder

func (*SelectBuilder) Write added in v1.2.1

func (this *SelectBuilder) Write(w Writer) (err error)

type Session added in v1.0.4

type Session interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

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

	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

type Statement

type Statement interface {
	Write(w Writer) error
	SQL() (string, []interface{}, error)
}

func IN

func IN(sql string, args interface{}) Statement

func Like

func Like(sql string, args ...interface{}) Statement

func NotIn

func NotIn(sql string, args interface{}) Statement

func NotLike

func NotLike(sql string, args ...interface{}) Statement

type TX

type TX interface {
	DB

	// Id 获取事务 id
	Id() string

	// String 返回事务描述
	String() string

	// Trace 添加日志信息
	Trace(string)

	// Commit 提交事务
	Commit() (err error)

	// Rollback 回滚事务
	Rollback() error

	Stmt(stmt *sql.Stmt) *sql.Stmt

	StmtContext(ctx context.Context, stmt *sql.Stmt) *sql.Stmt
	// contains filtered or unexported methods
}

func MustTx

func MustTx(db DB) TX

func MustTxContext

func MustTxContext(ctx context.Context, db DB, opts *sql.TxOptions) TX

func NewTx

func NewTx(db DB) (TX, error)

func NewTxContext

func NewTxContext(ctx context.Context, db DB, opts *sql.TxOptions) (tx TX, err error)

type UpdateBuilder

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

func NewUpdateBuilder

func NewUpdateBuilder() *UpdateBuilder

func Update

func Update(table string, args ...string) *UpdateBuilder

func (*UpdateBuilder) Exec

func (this *UpdateBuilder) Exec(s Session) (sql.Result, error)

func (*UpdateBuilder) ExecContext

func (this *UpdateBuilder) ExecContext(ctx context.Context, s Session) (result sql.Result, err error)

func (*UpdateBuilder) GetDialect added in v1.1.7

func (this *UpdateBuilder) GetDialect() Dialect

func (*UpdateBuilder) Join

func (this *UpdateBuilder) Join(join, table, suffix string, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) LeftJoin

func (this *UpdateBuilder) LeftJoin(table, suffix string, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) Limit

func (this *UpdateBuilder) Limit(limit int64) *UpdateBuilder

func (*UpdateBuilder) Offset

func (this *UpdateBuilder) Offset(offset int64) *UpdateBuilder

func (*UpdateBuilder) Options

func (this *UpdateBuilder) Options(options ...string) *UpdateBuilder

func (*UpdateBuilder) OrderBy

func (this *UpdateBuilder) OrderBy(sql ...string) *UpdateBuilder

func (*UpdateBuilder) Prefix

func (this *UpdateBuilder) Prefix(sql string, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) RightJoin

func (this *UpdateBuilder) RightJoin(table, suffix string, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) SET

func (this *UpdateBuilder) SET(column string, value interface{}) *UpdateBuilder

func (*UpdateBuilder) SETS

func (this *UpdateBuilder) SETS(kvs ...interface{}) *UpdateBuilder

SETS 批量设置需要更新的字段及其值 var name = "my name" SETS("name", name, "age", 10)

func (*UpdateBuilder) SQL added in v1.2.1

func (this *UpdateBuilder) SQL() (string, []interface{}, error)

func (*UpdateBuilder) SetMap

func (this *UpdateBuilder) SetMap(data map[string]interface{}) *UpdateBuilder

func (*UpdateBuilder) Suffix

func (this *UpdateBuilder) Suffix(sql interface{}, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) Table

func (this *UpdateBuilder) Table(table string, args ...string) *UpdateBuilder

func (*UpdateBuilder) Type

func (this *UpdateBuilder) Type() string

func (*UpdateBuilder) UseDialect

func (this *UpdateBuilder) UseDialect(d Dialect) *UpdateBuilder

func (*UpdateBuilder) Where

func (this *UpdateBuilder) Where(sql interface{}, args ...interface{}) *UpdateBuilder

func (*UpdateBuilder) Write added in v1.2.1

func (this *UpdateBuilder) Write(w Writer) (err error)

type Writer added in v1.0.3

type Writer interface {
	Write(p []byte) (n int, err error)

	WriteString(s string) (n int, err error)

	WriteArgs(args ...interface{})
}

Directories

Path Synopsis
examples module
tools
tx

Jump to

Keyboard shortcuts

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