本文整理匯總了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
}