Versions in this module Expand all Collapse all v1 v1.0.1 Dec 15, 2022 v1.0.0 Jan 14, 2022 Changes in this version + var ErrInitResource = errors.New("ezorm/db: failed to initial mongo resource") + var ErrOperaBeforeInit = errors.New("please set db.SetOnFinishInit when needed operating db in init()") + 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 func(ctx context.Context, query string, args ...interface{}) (interface{}, error) + func SQLServerTracerWrapper(ctx context.Context, queryer ContextQueryer, query string, args ...interface{}) ContextQueryer + type M bson.M + func In(ids []string) M + func InID(ids []string) (ret M) + func (m M) Update(qs ...M) M + type MongoConfig struct + DBName string + MaxSession int + MongoDB string + PoolLimit int + type Mysql struct + func GetMysql() *Mysql + func NewMysql(cfg *MysqlConfig) (*Mysql, error) + type MysqlConfig struct + ConnMaxLifeTime time.Duration + DataSource string + PoolSize int + type MysqlFieldConfig struct + Addr string + ConnMaxLifeTime time.Duration + Database string + Options map[string]string + Password string + PoolSize int + UserName string + func (cfg *MysqlFieldConfig) Convert() *MysqlConfig + type QueryContextWrapper func(ctx context.Context, queryer ContextQueryer, query string, args ...interface{}) ContextQueryer + type QueryWrapper func(queryer Queryer, query string, args ...interface{}) Queryer + type Queryer func(query string, args ...interface{}) (interface{}, error) + type RedisStore struct + func NewRedisStore(host string, port int, password string, db int) (*RedisStore, error) + func (r *RedisStore) StringScan(str string, val interface{}) error + type SqlServer struct + func GetSqlServer(dataSourceName string) *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 Other modules containing this package github.com/ezbuy/ezorm/v2