package store import ( "context" "uauth/tool" "gorm.io/gorm" ) type Store interface { Session(ctx context.Context) *gorm.DB } var ( Default *Client ) type Client struct { ctx context.Context cli *gorm.DB ttype string debug bool } func (c *Client) Type() string { return c.ttype } func (c *Client) Session(ctx context.Context) *gorm.DB { if ctx == nil { ctx = tool.Timeout(30) } session := c.cli.Session(&gorm.Session{Context: ctx}) if c.debug { session = session.Debug() } return session } func (c *Client) Close() { d, _ := c.cli.DB() d.Close() }