add func (eg *EngineGroup) Context(ctx context.Context) *Session (#1267)

This commit is contained in:
jixiuf 2019-04-10 11:27:55 +08:00 committed by BetaCat
parent 617e0ae295
commit 06528a4d83
1 changed files with 8 additions and 0 deletions

View File

@ -5,6 +5,7 @@
package xorm
import (
"context"
"time"
"github.com/go-xorm/core"
@ -74,6 +75,13 @@ func (eg *EngineGroup) Close() error {
return nil
}
// Context returned a group session
func (eg *EngineGroup) Context(ctx context.Context) *Session {
sess := eg.NewSession()
sess.isAutoClose = true
return sess.Context(ctx)
}
// NewSession returned a group session
func (eg *EngineGroup) NewSession() *Session {
sess := eg.Engine.NewSession()