session

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

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

Hooks constants

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonDB

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

CommonDB is a minimal function set of db

type Session

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

func New

func New(db *sql.DB, dialector dialect.Dialector, log *elog.Log) *Session

func (*Session) Begin

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

func (*Session) CallMethod

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

CallMethod calls the registered hooks

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

CreateTable create a table in database with a model

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

DropTable drops a table with the name of model

func (*Session) Exec

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

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

HasTable returns true of the table exists

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(model interface{}) *Session

Model assigns refTable

func (*Session) OrderBy

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

func (*Session) Query

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

func (*Session) QueryRow

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

func (*Session) Raw

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

func (*Session) Rollback

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

func (*Session) Table

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

Table returns a Schema instance that contains all parsed fields

func (*Session) Update

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

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