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

This commit is contained in:
jixiufeng 2019-04-09 10:50:45 +08:00
parent 617e0ae295
commit d1d0f66fa9
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()