session

package
v0.0.0-...-8a62f83 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeforeQuery  = "BeforeQuery"
	AfterQuery   = "AfterQuery"
	BeforeUpdate = "BeforeUpdate"
	AfterUpdate  = "AfterUpdate"
	BeforeDelete = "BeforeDelete"
	AfterDelete  = "AfterDelete"
	BeforeInsert = "BeforeInsert"
	AfterInsert  = "AfterInsert"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonDB

type CommonDB interface {
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type Session

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

与db交互

func New

func New(db *sql.DB, dialect dialect.Dialect) *Session

func (*Session) Begin

func (s *Session) Begin() (err error)

func (*Session) CallMethod

func (s *Session) CallMethod(method string, value interface{})

func (*Session) Clear

func (s *Session) Clear()

func (*Session) Commit

func (s *Session) Commit() (err error)

func (*Session) Count

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

func (*Session) CreateTable

func (s *Session) CreateTable() error

func (*Session) DB

func (s *Session) DB() CommonDB

func (*Session) Delete

func (s *Session) Delete() (int64, error)

func (*Session) DropTable

func (s *Session) DropTable() error

func (*Session) Exec

func (s *Session) Exec() (result sql.Result, err error)

执行sql语句

func (*Session) Find

func (s *Session) Find(values interface{}) error

func (*Session) First

func (s *Session) First(value interface{}) error

func (*Session) HasTable

func (s *Session) HasTable() bool

func (*Session) Insert

func (s *Session) Insert(values ...interface{}) (int64, error)

func (*Session) Limit

func (s *Session) Limit(num int) *Session

func (*Session) Model

func (s *Session) Model(value interface{}) *Session

func (*Session) OrderBy

func (s *Session) OrderBy(desc string) *Session

func (*Session) QueryRow

func (s *Session) QueryRow() *sql.Row

查询单条记录

func (*Session) QueryRows

func (s *Session) QueryRows() (rows *sql.Rows, err error)

查询多条记录

func (*Session) Raw

func (s *Session) Raw(sql string, values ...interface{}) *Session

func (*Session) RefTable

func (s *Session) RefTable() *schema.Schema

func (*Session) Rollback

func (s *Session) Rollback() (err error)

func (*Session) Update

func (s *Session) Update(kv ...interface{}) (int64, error)

支持map[string]interface{} 同时支持kv键值对 "name","Lily","id",123

func (*Session) Where

func (s *Session) Where(desc string, args ...interface{}) *Session

Jump to

Keyboard shortcuts

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