本文整理汇总了Golang中github.com/cosiner/gomodel.DB类的典型用法代码示例。如果您正苦于以下问题:Golang DB类的具体用法?Golang DB怎么用?Golang DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: txDo
func (f *Follow) txDo(db *gomodel.DB, do func(gomodel.Tx, *Follow) error) (err error) {
tx, err := db.Begin()
if err != nil {
return
}
defer tx.DeferDone(&err)
err = do(tx, f)
return
}
示例2: txDo
func (m *message) txDo(db *gomodel.DB, do func(*gomodel.Tx, *message) error) error {
tx, err := db.Begin()
if err != nil {
return err
}
defer tx.Close()
err = do(tx, m)
tx.Success(err == nil)
return err
}
示例3: txDo
func (f *Follow) txDo(db *gomodel.DB, do func(*gomodel.Tx, *Follow) error) error {
tx, err := db.Begin()
if err != nil {
return err
}
defer tx.Close()
err = do(tx, f)
tx.Success(err == nil)
return err
}
示例4: NewDBBackend
func NewDBBackend(db *gomodel.DB, timeFormat string) (b gotmsq.Backend, err error) {
d := &DB{timeFormat: timeFormat}
b = d
defer func(d *DB, err *error) {
if *err == nil {
return
}
if d.stmtClearTimeout != nil {
d.stmtClearTimeout.Close()
}
if d.stmtInsert != nil {
d.stmtInsert.Close()
}
if d.stmtQueryMessage != nil {
d.stmtQueryMessage.Close()
}
if d.stmtDeleteById != nil {
d.stmtDeleteById.Close()
}
}(d, &err)
d.stmtClearTimeout, err = db.StmtById(deleteTimeoutMessagesSQL)
if err != nil {
return
}
d.stmtQueryMessage, err = db.StmtById(queryMessageSQL)
if err != nil {
return
}
d.stmtDeleteById, err = db.StmtById(deleteMessageByIdSQL)
if err != nil {
return
}
d.stmtInsert, err = db.StmtById(insertMessageSQL)
if err != nil {
return
}
return
}