expose functions to use sessions

This commit is contained in:
bergquist
2018-06-18 14:50:36 +02:00
parent 2b849086a1
commit 3479cf4b39
2 changed files with 69 additions and 11 deletions
+10 -10
View File
@@ -27,18 +27,18 @@ func startSession(ctx context.Context, engine *xorm.Engine, beginTran bool) (*DB
var sess *DBSession
sess, ok := value.(*DBSession)
if !ok {
newSess := &DBSession{Session: engine.NewSession()}
if beginTran {
err := newSess.Begin()
if err != nil {
return nil, err
}
}
return newSess, nil
if ok {
return sess, nil
}
return sess, nil
newSess := &DBSession{Session: engine.NewSession()}
if beginTran {
err := newSess.Begin()
if err != nil {
return nil, err
}
}
return newSess, nil
}
func withDbSession(ctx context.Context, callback dbTransactionFunc) error {