Documentation
¶
Index ¶
- Variables
- func EnsureAllIndex()
- func GetCol(dbName, col string) (session *mgo.Session, collection *mgo.Collection)
- func IsFinishInit() bool
- func IsMgoDup(err error) bool
- func IsMgoNotFound(err error) bool
- func MustNewMgoSessions(config *MongoConfig) []*mgo.Session
- func MysqlExec(query string, args ...interface{}) (sql.Result, error)
- func MysqlInit(cfg *MysqlConfig)
- func MysqlInitByField(cfg *MysqlFieldConfig)
- func MysqlQuery(query string, args ...interface{}) (*sql.Rows, error)
- func MysqlQueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func NewCollection(session *mgo.Session, dbName, name string) *mgo.Collection
- func NewObjectId() bson.ObjectId
- func NewSession() (session *mgo.Session)
- func ObjectIds(ids []string) (ret []bson.ObjectId)
- func SetOnEnsureIndex(f func())
- func SetOnFinishInit(f func())
- func Setup(c *MongoConfig)
- func SetupIdleSessionRefresher(config *MongoConfig, instances []*mgo.Session, every time.Duration)
- func ShareSession() *mgo.Session
- func TimeFormat(t time.Time) string
- func TimeParse(s string) time.Time
- func TimeParseLocalTime(s string) time.Time
- func TimeToLocalTime(c time.Time) string
- type ContextQueryer
- type M
- type MongoConfig
- type Mysql
- type MysqlConfig
- type MysqlFieldConfig
- type QueryContextWrapper
- type QueryWrapper
- type Queryer
- type RedisStore
- type SqlServer
- func (s *SqlServer) AddQueryContextWrapper(wrapper QueryContextWrapper)
- func (s *SqlServer) AddQueryWrapper(wrapper QueryWrapper)
- func (s *SqlServer) Exec(query string, args ...interface{}) (sql.Result, error)
- func (s *SqlServer) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (s *SqlServer) GetContextWrappers() []QueryContextWrapper
- func (s *SqlServer) GetWrappers() []QueryWrapper
- func (s *SqlServer) Query(dest interface{}, query string, args ...interface{}) error
- func (s *SqlServer) QueryContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInitResource = errors.New("ezorm/db: failed to initial mongo resource")
View Source
var ErrOperaBeforeInit = errors.New("please set db.SetOnFinishInit when needed operating db in init()")
Functions ¶
func EnsureAllIndex ¶
func EnsureAllIndex()
func IsFinishInit ¶
func IsFinishInit() bool
func IsMgoNotFound ¶
func MustNewMgoSessions ¶
func MustNewMgoSessions(config *MongoConfig) []*mgo.Session
func MysqlInit ¶
func MysqlInit(cfg *MysqlConfig)
func MysqlInitByField ¶
func MysqlInitByField(cfg *MysqlFieldConfig)
func MysqlQueryContext ¶
func NewCollection ¶
func NewCollection(session *mgo.Session, dbName, name string) *mgo.Collection
func NewObjectId ¶
func NewSession ¶
func SetOnEnsureIndex ¶
func SetOnEnsureIndex(f func())
func SetOnFinishInit ¶
func SetOnFinishInit(f func())
func Setup ¶
func Setup(c *MongoConfig)
func SetupIdleSessionRefresher ¶
func SetupIdleSessionRefresher(config *MongoConfig, instances []*mgo.Session, every time.Duration)
SetupIdleSessionRefresher will always refresh idle sessions if it is possible
func ShareSession ¶
func TimeFormat ¶
func TimeParseLocalTime ¶
func TimeToLocalTime ¶
Types ¶
type ContextQueryer ¶
type ContextQueryer func(ctx context.Context, query string, args ...interface{}) (interface{}, error)
func SQLServerTracerWrapper ¶
func SQLServerTracerWrapper(ctx context.Context, queryer ContextQueryer, query string, args ...interface{}) ContextQueryer
type MongoConfig ¶
type MysqlConfig ¶
type MysqlFieldConfig ¶
type MysqlFieldConfig struct { Addr string UserName string Password string Database string PoolSize int ConnMaxLifeTime time.Duration Options map[string]string }
MysqlFieldConfig uses fields to config mysql, it can be converted to DSN style.
func (*MysqlFieldConfig) Convert ¶
func (cfg *MysqlFieldConfig) Convert() *MysqlConfig
type QueryContextWrapper ¶
type QueryContextWrapper func(ctx context.Context, queryer ContextQueryer, query string, args ...interface{}) ContextQueryer
type QueryWrapper ¶
type RedisStore ¶
func NewRedisStore ¶
func (*RedisStore) StringScan ¶
func (r *RedisStore) StringScan(str string, val interface{}) error
! functions
type SqlServer ¶
func GetSqlServer ¶
func (*SqlServer) AddQueryContextWrapper ¶
func (s *SqlServer) AddQueryContextWrapper(wrapper QueryContextWrapper)
func (*SqlServer) AddQueryWrapper ¶
func (s *SqlServer) AddQueryWrapper(wrapper QueryWrapper)
func (*SqlServer) ExecContext ¶
func (*SqlServer) GetContextWrappers ¶
func (s *SqlServer) GetContextWrappers() []QueryContextWrapper
func (*SqlServer) GetWrappers ¶
func (s *SqlServer) GetWrappers() []QueryWrapper
Click to show internal directories.
Click to hide internal directories.