orm

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: GPL-3.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound added in v1.2.6

func IsNotFound(err error) bool

IsNotFound error为not found.

Types

type DB

type DB struct {
	IP       string
	Port     int
	DBName   string
	UserName string
	Passwd   string
	Charset  string
	Timeout  int
}

DB db instance.

func NewDB

func NewDB(ip string, port int, dbName, user, pass, charset string, timeout int) *DB

NewDB create db instance, timeout 单位:秒.

func (*DB) GetConnection

func (db *DB) GetConnection() (*sql.DB, error)

GetConnection open new connect to db.

type Stmt

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

Stmt db stmt.

func NewStmt

func NewStmt(db *sql.DB, table string) *Stmt

NewStmt new db stmt.

func (*Stmt) BatchInsert added in v1.11.1

func (s *Stmt) BatchInsert(data []interface{}) ([]int64, error)

BatchInsert 数组插入

func (*Stmt) Count

func (s *Stmt) Count() (int64, error)

Count 查询总数.

func (*Stmt) Exec added in v1.2.0

func (s *Stmt) Exec(query string, args ...interface{}) (int64, error)

Exec 保留的原始执行接口.

func (*Stmt) Group

func (s *Stmt) Group(group string) *Stmt

Group 添加group by.

func (*Stmt) Insert

func (s *Stmt) Insert(data interface{}) (int64, error)

Insert sql update db.

func (*Stmt) Limit

func (s *Stmt) Limit(limit int) *Stmt

Limit 添加limit

func (*Stmt) Offset

func (s *Stmt) Offset(offset int) *Stmt

Offset 添加offset

func (*Stmt) Order

func (s *Stmt) Order(order string) *Stmt

Order 添加order

func (*Stmt) Query

func (s *Stmt) Query(result interface{}) error

Query 根据传入的result结构,生成查询sql,并返回执行结果, result 必需是一个指向切片的指针.

func (*Stmt) Raw added in v1.11.1

func (s *Stmt) Raw(query string, args ...interface{}) *Stmt

Raw 原始sql.

func (*Stmt) SetLogger added in v1.3.1

func (s *Stmt) SetLogger(l *log.Logger) *Stmt

SetLogger 输出log.

func (*Stmt) Sort

func (s *Stmt) Sort(sort string) *Stmt

Sort 添加sort

func (*Stmt) Update

func (s *Stmt) Update(data interface{}) (int64, error)

Update sql update db.

func (*Stmt) Where

func (s *Stmt) Where(f string, args ...interface{}) *Stmt

Where 添加查询条件

Jump to

Keyboard shortcuts

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