Documentation ¶
Index ¶
- Constants
- Variables
- func GetPkValue(m Model) (string, interface{})
- type Database
- func (d *Database) Close()
- func (d *Database) Del(m Model, field string, value interface{}) (affect int64, err error)
- func (d *Database) DelPk(m Model) (int64, error)
- func (d *Database) Get(m Model, field string, value interface{}) error
- func (d *Database) GetCondition(m Model, condition interface{}, value ...interface{}) ([]Model, error)
- func (d *Database) GetMultiIn(m Model, field string, value ...interface{}) ([]Model, error)
- func (d *Database) GetMultiPkIn(m Model, value ...interface{}) ([]Model, error)
- func (d *Database) GetPk(m Model) error
- func (d *Database) Insert(m Model) (last int64, err error)
- func (d *Database) Select(m Model, field string, condition interface{}, value ...interface{}) (ms []Model, err error)
- func (d *Database) Update(m Model, field string, value interface{}) (affect int64, err error)
- func (d *Database) UpdatePk(m Model) (int64, error)
- type DeafultModel
- type Model
- type Scanner
Constants ¶
View Source
const (
TIME_FORMATER = "2006-01-02 15:04:05"
)
Variables ¶
View Source
var (
TIME_PTR_TYPE = reflect.TypeOf(&time.Time{})
)
Functions ¶
func GetPkValue ¶
Types ¶
type Database ¶
type Database struct { Debug bool // contains filtered or unexported fields }
func (*Database) GetCondition ¶
func (d *Database) GetCondition(m Model, condition interface{}, value ...interface{}) ([]Model, error)
d.GetCondition(&User{}, "where level >10 and money <? limit ?, 10", 100, 5)
func (*Database) GetMultiIn ¶
mysql in usage ms := d.GetMultiIn(&User{}, "openid", "12", "34") ms[0].(*User) [return interface{} need type change]
func (*Database) GetMultiPkIn ¶
type DeafultModel ¶
type DeafultModel struct{}
if you don't want provide TableName, you can combine DeafultModel
func (*DeafultModel) TableName ¶
func (m *DeafultModel) TableName() string
Click to show internal directories.
Click to hide internal directories.