Documentation
¶
Index ¶
- func MysqlExec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func MysqlInit(cfg *MysqlConfig)
- func MysqlInitByField(cfg *MysqlFieldConfig)
- func MysqlQuery(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func Setup(c *MongoConfig)
- func SetupMany(cs ...*MongoConfig)
- func SetupRawDB(db *sql.DB)
- 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 GetMySQLOption
- type GetMySQLOptionFunc
- type MongoConfig
- type MongoDriver
- type MongoDriverConnOption
- type MongoDriverConnOptionFn
- type MongoDriverOption
- type Mysql
- type MysqlConfig
- type MysqlFieldConfig
- type NewMySQLOption
- type NewMySQLOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MysqlInit ¶
func MysqlInit(cfg *MysqlConfig)
func MysqlInitByField ¶
func MysqlInitByField(cfg *MysqlFieldConfig)
func MysqlQuery ¶
func Setup ¶
func Setup(c *MongoConfig)
Setup setup one mongo config For multiple configs, use `SetupMany` instead
func SetupMany ¶ added in v0.0.14
func SetupMany( cs ...*MongoConfig, )
SetupMany setup many mongo configs For singleton , use `Setup` instead
func SetupRawDB ¶
func TimeFormat ¶
func TimeParseLocalTime ¶
func TimeToLocalTime ¶
Types ¶
type GetMySQLOption ¶
type GetMySQLOption struct {
// contains filtered or unexported fields
}
type GetMySQLOptionFunc ¶
type GetMySQLOptionFunc func(*GetMySQLOption)
func WithDB ¶
func WithDB(db *sql.DB) GetMySQLOptionFunc
type MongoConfig ¶
func GetConfig ¶ added in v0.0.14
func GetConfig(name string) *MongoConfig
func GetConfigByName ¶ added in v0.0.14
func GetConfigByName(name string) *MongoConfig
type MongoDriver ¶
type MongoDriver struct {
// contains filtered or unexported fields
}
func NewMongoDriver ¶
func NewMongoDriver(ctx context.Context, opts ...MongoDriverOption) (*MongoDriver, error)
func NewMongoDriverBy ¶ added in v0.0.14
func NewMongoDriverBy( ctx context.Context, opts ...MongoDriverConnOptionFn, ) (*MongoDriver, error)
func (*MongoDriver) Close ¶
func (md *MongoDriver) Close() error
func (*MongoDriver) GetCol ¶
func (md *MongoDriver) GetCol(cname string) *mongo.Collection
type MongoDriverConnOption ¶ added in v0.0.14
type MongoDriverConnOption struct {
// contains filtered or unexported fields
}
type MongoDriverConnOptionFn ¶ added in v0.0.14
type MongoDriverConnOptionFn func(*MongoDriverConnOption)
func WithClientOption ¶ added in v0.0.14
func WithClientOption(opt MongoDriverOption) MongoDriverConnOptionFn
func WithDBName ¶ added in v0.0.14
func WithDBName(dbName string) MongoDriverConnOptionFn
type MongoDriverOption ¶
type MongoDriverOption func(*options.ClientOptions)
func WithPoolMonitor ¶
func WithPoolMonitor(m *event.PoolMonitor) MongoDriverOption
type Mysql ¶
func GetMysql ¶
func GetMysql(opts ...GetMySQLOptionFunc) *Mysql
func NewMysql ¶
func NewMysql(cfg *MysqlConfig, opts ...NewMySQLOptionFunc) (*Mysql, error)
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 NewMySQLOption ¶
type NewMySQLOption struct {
// contains filtered or unexported fields
}
type NewMySQLOptionFunc ¶
type NewMySQLOptionFunc func(*NewMySQLOption)
func WithRawDB ¶
func WithRawDB(db *sql.DB) NewMySQLOptionFunc
Click to show internal directories.
Click to hide internal directories.