Documentation
¶
Index ¶
- Constants
- Variables
- func FileWithLineNum() string
- func NewDbPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewHttpPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMaxMindPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMemCachePool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMemoryPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- func NewMongoPool(iObj iface.IObject, args ...interface{}) iface.IObject
- func NewRabbitMqPool(iObj iface.IObject, dftConfig ...interface{}) iface.IObject
- func NewRedisPool(iObj iface.IObject, componentId ...interface{}) iface.IObject
- type CAggregate
- type CQuery
- func (c *CQuery) All(result interface{}) error
- func (c *CQuery) Apply(change qmgo.Change, result interface{}) error
- func (c *CQuery) Count() (n int64, err error)
- func (c *CQuery) Distinct(key string, result interface{}) error
- func (c *CQuery) Hint(hint interface{}) qmgo.QueryI
- func (c *CQuery) Limit(n int64) qmgo.QueryI
- func (c *CQuery) One(result interface{}) error
- func (c *CQuery) Prepare(q qmgo.QueryI, dftCtxCancel ...context.CancelFunc)
- func (c *CQuery) Select(selector interface{}) qmgo.QueryI
- func (c *CQuery) Skip(n int64) qmgo.QueryI
- func (c *CQuery) Sort(fields ...string) qmgo.QueryI
- type Db
- func (d *Db) Begin(opts ...*sql.TxOptions) ITx
- func (d *Db) BeginContext(ctx context.Context, opts *sql.TxOptions) ITx
- func (d *Db) Exec(query string, args ...interface{}) sql.Result
- func (d *Db) ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
- func (d *Db) GetClient() *db.Client
- func (d *Db) GetDb(master bool) *sql.DB
- func (d *Db) Master() bool
- func (d *Db) Prepare(componentId ...interface{})
- func (d *Db) PrepareContext(ctx context.Context, query string) IStmt
- func (d *Db) PrepareSql(query string) IStmt
- func (d *Db) Query(query string, args ...interface{}) *sql.Rows
- func (d *Db) QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows
- func (d *Db) QueryOne(query string, args ...interface{}) IRow
- func (d *Db) QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow
- func (d *Db) SetMaster(v bool)
- type Es
- type Http
- func (h *Http) Do(req *http.Request, option ...*phttp.Option) *http.Response
- func (h *Http) DoMulti(requests []*http.Request, option ...*phttp.Option) []*http.Response
- func (h *Http) Get(addr string, data interface{}, option ...*phttp.Option) *http.Response
- func (h *Http) GetClient() *phttp.Client
- func (h *Http) Post(addr string, data interface{}, option ...*phttp.Option) *http.Response
- func (h *Http) Prepare(componentId ...interface{})
- func (h *Http) SetPanicRecover(v bool)
- type IDb
- type IEs
- type IHttp
- type IMaxMind
- type IMemCache
- type IMemory
- type IMongo
- type IMongodb
- type IMongodbAggregate
- type IMongodbQuery
- type IOrm
- type IRabbitMq
- type IRedis
- type IRow
- type IStmt
- type ITx
- type MaxMind
- type MemCache
- func (m *MemCache) Add(key string, value interface{}, expire ...time.Duration) bool
- func (m *MemCache) Del(key string) bool
- func (m *MemCache) Exists(key string) bool
- func (m *MemCache) Get(key string) *value.Value
- func (m *MemCache) GetClient() *memcache.Client
- func (m *MemCache) Incr(key string, delta int) int
- func (m *MemCache) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (m *MemCache) MDel(keys []string) bool
- func (m *MemCache) MGet(keys []string) map[string]*value.Value
- func (m *MemCache) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (m *MemCache) MultiRetrieve(cmd string, keys []string) []*memcache.Item
- func (m *MemCache) MultiStore(cmd string, items []*memcache.Item, expire ...time.Duration) bool
- func (m *MemCache) Prepare(componentId ...interface{})
- func (m *MemCache) Retrieve(cmd, key string) *memcache.Item
- func (m *MemCache) Set(key string, value interface{}, expire ...time.Duration) bool
- func (m *MemCache) SetPanicRecover(v bool)
- func (m *MemCache) Store(cmd string, item *memcache.Item, expire ...time.Duration) bool
- type Memory
- func (m *Memory) Add(key string, value interface{}, expire ...time.Duration) bool
- func (m *Memory) Client() *memory.Client
- func (m *Memory) Del(key string) bool
- func (m *Memory) Exists(key string) bool
- func (m *Memory) Get(key string) *value.Value
- func (m *Memory) Incr(key string, delta int) int
- func (m *Memory) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (m *Memory) MDel(keys []string) bool
- func (m *Memory) MGet(keys []string) map[string]*value.Value
- func (m *Memory) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (m *Memory) Prepare(componentId ...interface{})
- func (m *Memory) Set(key string, value interface{}, expire ...time.Duration) bool
- func (m *Memory) SetPanicRecover(v bool)
- type Mongo
- func (m *Mongo) Count(query interface{}, options ...bson.M) (int, error)
- func (m *Mongo) DeleteAll(query interface{}) error
- func (m *Mongo) DeleteOne(query interface{}) error
- func (m *Mongo) FindAll(query interface{}, result interface{}, options ...bson.M) error
- func (m *Mongo) FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error
- func (m *Mongo) FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error
- func (m *Mongo) FindOne(query interface{}, result interface{}, options ...bson.M) error
- func (m *Mongo) GetClient() *mongo.Client
- func (m *Mongo) InsertAll(docs []interface{}) error
- func (m *Mongo) InsertOne(doc interface{}) error
- func (m *Mongo) MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error
- func (m *Mongo) PipeAll(pipeline interface{}, result interface{}) error
- func (m *Mongo) PipeOne(pipeline interface{}, result interface{}) error
- func (m *Mongo) Prepare(args ...interface{})
- func (m *Mongo) UpdateAll(query interface{}, update interface{}) error
- func (m *Mongo) UpdateOne(query interface{}, update interface{}) error
- func (m *Mongo) UpdateOrInsert(query interface{}, update interface{}) error
- type Mongodb
- func (m *Mongodb) Aggregate(pipeline interface{}) IMongodbAggregate
- func (m *Mongodb) AggregateCtx(ctx context.Context, pipeline interface{}) IMongodbAggregate
- func (m *Mongodb) CloneCollection() (*mongo.Collection, error)
- func (m *Mongodb) Count(filter interface{}) (int, error)
- func (m *Mongodb) CreateIndexes(indexes []opts.IndexModel) (err error)
- func (m *Mongodb) CreateIndexesCtx(ctx context.Context, indexes []opts.IndexModel) (err error)
- func (m *Mongodb) CreateOneIndex(index opts.IndexModel) error
- func (m *Mongodb) CreateOneIndexCtx(ctx context.Context, index opts.IndexModel) (err error)
- func (m *Mongodb) DeleteAll(filter interface{}) error
- func (m *Mongodb) DeleteOne(filter interface{}) error
- func (m *Mongodb) DoTransaction(ctx context.Context, ...) (interface{}, error)
- func (m *Mongodb) DropAllIndexes() (err error)
- func (m *Mongodb) DropAllIndexesCtx(ctx context.Context) (err error)
- func (m *Mongodb) DropCollection() error
- func (m *Mongodb) DropCollectionCtx(ctx context.Context) error
- func (m *Mongodb) DropIndex(indexes []string) error
- func (m *Mongodb) DropIndexCtx(ctx context.Context, indexes []string) error
- func (m *Mongodb) EnsureIndexes(uniques []string, indexes []string) (err error)
- func (m *Mongodb) EnsureIndexesCtx(ctx context.Context, uniques []string, indexes []string) (err error)
- func (m *Mongodb) Find(filter interface{}, options ...opts.FindOptions) IMongodbQuery
- func (m *Mongodb) FindAll(filter interface{}, doc interface{}, options ...bson.M) (err error)
- func (m *Mongodb) FindAndModify(query interface{}, change qmgo.Change, result interface{}, options ...bson.M) error
- func (m *Mongodb) FindCtx(ctx context.Context, filter interface{}, options ...opts.FindOptions) IMongodbQuery
- func (m *Mongodb) FindOne(filter interface{}, doc interface{}, options ...bson.M) (err error)
- func (m *Mongodb) GetClient() *mongodb.Client
- func (m *Mongodb) GetCollectionName() string
- func (m *Mongodb) InsertAll(docs interface{}) error
- func (m *Mongodb) InsertMany(docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error)
- func (m *Mongodb) InsertManyCtx(ctx context.Context, docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error)
- func (m *Mongodb) InsertOne(doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error)
- func (m *Mongodb) InsertOneCtx(ctx context.Context, doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error)
- func (m *Mongodb) PipeAll(query interface{}, doc interface{}) error
- func (m *Mongodb) PipeOne(pipeline interface{}, result interface{}) error
- func (m *Mongodb) Prepare(db, coll string, componentId ...string)
- func (m *Mongodb) Remove(filter interface{}, opts ...opts.RemoveOptions) (err error)
- func (m *Mongodb) RemoveAll(filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error)
- func (m *Mongodb) RemoveAllCtx(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error)
- func (m *Mongodb) RemoveCtx(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (err error)
- func (m *Mongodb) RemoveId(id interface{}, opts ...opts.RemoveOptions) (err error)
- func (m *Mongodb) RemoveIdCtx(ctx context.Context, id interface{}, opts ...opts.RemoveOptions) (err error)
- func (m *Mongodb) ReplaceOne(filter interface{}, doc interface{}, opts ...opts.ReplaceOptions) (err error)
- func (m *Mongodb) ReplaceOneCtx(ctx context.Context, filter interface{}, doc interface{}, ...) (err error)
- func (m *Mongodb) Session() (*qmgo.Session, error)
- func (m *Mongodb) UpdateAll(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (result *qmgo.UpdateResult, err error)
- func (m *Mongodb) UpdateAllCtx(ctx context.Context, filter interface{}, update interface{}, ...) (result *qmgo.UpdateResult, err error)
- func (m *Mongodb) UpdateId(id interface{}, update interface{}, opts ...opts.UpdateOptions) (err error)
- func (m *Mongodb) UpdateIdCtx(ctx context.Context, id interface{}, update interface{}, ...) (err error)
- func (m *Mongodb) UpdateOne(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (err error)
- func (m *Mongodb) UpdateOneCtx(ctx context.Context, filter interface{}, update interface{}, ...) (err error)
- func (m *Mongodb) UpdateOrInsert(query interface{}, doc interface{}) error
- func (m *Mongodb) Upsert(filter interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
- func (m *Mongodb) UpsertCtx(ctx context.Context, filter interface{}, replacement interface{}, ...) (result *qmgo.UpdateResult, err error)
- func (m *Mongodb) UpsertId(id interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
- func (m *Mongodb) UpsertIdCtx(ctx context.Context, id interface{}, replacement interface{}, ...) (result *qmgo.UpdateResult, err error)
- type Orm
- func (o *Orm) Assign(attrs ...interface{}) (tx IOrm)
- func (o *Orm) Attrs(attrs ...interface{}) (tx IOrm)
- func (o *Orm) Begin(opts ...*sql.TxOptions) (tx IOrm)
- func (o *Orm) Clauses(conds ...clause.Expression) (tx IOrm)
- func (o *Orm) Commit() (tx IOrm)
- func (o *Orm) Count(count *int64) (tx IOrm)
- func (o *Orm) Create(value interface{}) (tx IOrm)
- func (o *Orm) CreateInBatches(value interface{}, batchSize int) (tx IOrm)
- func (o *Orm) Debug() (tx IOrm)
- func (o *Orm) Delete(value interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) Distinct(args ...interface{}) (tx IOrm)
- func (o *Orm) Exec(sql string, values ...interface{}) (tx IOrm)
- func (o *Orm) Find(dest interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) FindInBatches(dest interface{}, batchSize int, fc func(pTx *gorm.DB, batch int) error) (tx IOrm)
- func (o *Orm) First(dest interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) FirstOrCreate(dest interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) FirstOrInit(dest interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) GetConfig() *gorm.Config
- func (o *Orm) GetError() error
- func (o *Orm) GetRowsAffected() int64
- func (o *Orm) GetStatement() *gorm.Statement
- func (o *Orm) Group(name string) (tx IOrm)
- func (o *Orm) Having(query interface{}, args ...interface{}) (tx IOrm)
- func (o *Orm) InstanceSet(key string, value interface{}) (tx IOrm)
- func (o *Orm) Joins(query string, args ...interface{}) (tx IOrm)
- func (o *Orm) Last(dest string, conds ...interface{}) (tx IOrm)
- func (o *Orm) Limit(limit int) (tx IOrm)
- func (o *Orm) Model(value interface{}) (tx IOrm)
- func (o *Orm) Not(query interface{}, args ...interface{}) (tx IOrm)
- func (o *Orm) Offset(offset int) (tx IOrm)
- func (o *Orm) Omit(columns ...string) (tx IOrm)
- func (o *Orm) Or(query interface{}, args ...interface{}) (tx IOrm)
- func (o *Orm) Order(value interface{}) (tx IOrm)
- func (o *Orm) Pluck(column string, dest interface{}) (tx IOrm)
- func (o *Orm) Preload(query string, args ...interface{}) (tx IOrm)
- func (o *Orm) Prepare(componentId ...interface{})
- func (o *Orm) Raw(sql string, values ...interface{}) (tx IOrm)
- func (o *Orm) Rollback() (tx IOrm)
- func (o *Orm) RollbackTo(name string) (tx IOrm)
- func (o *Orm) Row() *sql.Row
- func (o *Orm) Rows() (*sql.Rows, error)
- func (o *Orm) Save(value interface{}) (tx IOrm)
- func (o *Orm) SavePoint(name string) (tx IOrm)
- func (o *Orm) Scan(dest interface{}) (tx IOrm)
- func (o *Orm) Scopes(funcs ...func(*gorm.DB) *gorm.DB) (tx IOrm)
- func (o *Orm) Select(query interface{}, args ...interface{}) (tx IOrm)
- func (o *Orm) Session(config *gorm.Session) (tx IOrm)
- func (o *Orm) Set(key string, value interface{}) (tx IOrm)
- func (o *Orm) SqlDB() (*sql.DB, error)
- func (o *Orm) Table(name string, args ...interface{}) (tx IOrm)
- func (o *Orm) Take(dest interface{}, conds ...interface{}) (tx IOrm)
- func (o *Orm) Unscoped() (tx IOrm)
- func (o *Orm) Update(column string, value interface{}) (tx IOrm)
- func (o *Orm) UpdateColumn(column string, value interface{}) (tx IOrm)
- func (o *Orm) UpdateColumns(values interface{}) (tx IOrm)
- func (o *Orm) Updates(values interface{}) (tx IOrm)
- func (o *Orm) Where(query interface{}, args ...interface{}) (tx IOrm)
- func (o *Orm) WithContext(ctx context.Context) (tx IOrm)
- type RabbitMq
- func (r *RabbitMq) ChannelBox() *rabbitmq.ChannelBox
- func (r *RabbitMq) Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
- func (r *RabbitMq) ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, ...) <-chan amqp.Delivery
- func (r *RabbitMq) DecodeBody(d amqp.Delivery, ret interface{}) error
- func (r *RabbitMq) DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders
- func (r *RabbitMq) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData)
- func (r *RabbitMq) GetClient() *rabbitmq.Client
- func (r *RabbitMq) GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox
- func (r *RabbitMq) Prepare(dftConfig ...interface{})
- func (r *RabbitMq) Publish(opCode string, data interface{}, dftOpUid ...string) bool
- func (r *RabbitMq) PublishExchange(serviceName, exchangeName, exchangeType, opCode string, data interface{}, ...) bool
- func (r *RabbitMq) PublishExchangeDelivery(serviceName, exchangeName, exchangeType, opCode string, data interface{}, ...) bool
- func (r *RabbitMq) SetPanicRecover(v bool)
- type Redis
- func (r *Redis) Add(key string, value interface{}, expire ...time.Duration) bool
- func (r *Redis) Del(key string) bool
- func (r *Redis) Do(cmd string, args ...interface{}) interface{}
- func (r *Redis) Exists(key string) bool
- func (r *Redis) Expire(key string, expire time.Duration) bool
- func (r *Redis) ExpireAt(key string, timestamp int64) bool
- func (r *Redis) Get(key string) *value.Value
- func (r *Redis) GetClient() *redis.Client
- func (r *Redis) HDel(key string, fields ...interface{}) int64
- func (r *Redis) HExists(key, field string) bool
- func (r *Redis) HGet(key, field string) *value.Value
- func (r *Redis) HGetAll(key string) map[string]*value.Value
- func (r *Redis) HIncrBy(key, field string, delta int64) (int64, error)
- func (r *Redis) HMGet(key string, fields ...interface{}) map[string]*value.Value
- func (r *Redis) HMSet(key string, fv ...interface{}) bool
- func (r *Redis) HSet(key string, fv ...interface{}) bool
- func (r *Redis) Incr(key string, delta int) int
- func (r *Redis) IncrBy(key string, delta int64) (int64, error)
- func (r *Redis) LLen(key string) int64
- func (r *Redis) LPop(key string) *value.Value
- func (r *Redis) LPush(key string, values ...interface{}) bool
- func (r *Redis) MAdd(items map[string]interface{}, expire ...time.Duration) bool
- func (r *Redis) MDel(keys []string) bool
- func (r *Redis) MGet(keys []string) map[string]*value.Value
- func (r *Redis) MSet(items map[string]interface{}, expire ...time.Duration) bool
- func (r *Redis) Prepare(componentId ...interface{})
- func (r *Redis) RPop(key string) *value.Value
- func (r *Redis) RPush(key string, values ...interface{}) bool
- func (r *Redis) Set(key string, value interface{}, expire ...time.Duration) bool
- func (r *Redis) SetPanicRecover(v bool)
- func (r *Redis) ZAdd(key string, members ...*redis.Z) int64
- func (r *Redis) ZAddOpt(key string, opts []string, members ...*redis.Z) (int64, error)
- func (r *Redis) ZCard(key string) int64
- func (r *Redis) ZRange(key string, start, end int) []*value.Value
- func (r *Redis) ZRangeWithScores(key string, start, end int) []*redis.ZV
- func (r *Redis) ZRem(key string, members ...interface{}) int64
- func (r *Redis) ZRevRange(key string, start, end int) []*value.Value
- func (r *Redis) ZRevRangeWithScores(key string, start, end int) []*redis.ZV
- type Row
- type Stmt
- func (s *Stmt) Close()
- func (s *Stmt) Exec(args ...interface{}) sql.Result
- func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) sql.Result
- func (s *Stmt) Query(args ...interface{}) *sql.Rows
- func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) *sql.Rows
- func (s *Stmt) QueryOne(args ...interface{}) IRow
- func (s *Stmt) QueryOneContext(ctx context.Context, args ...interface{}) IRow
- type Tx
- func (t *Tx) Commit() bool
- func (t *Tx) Exec(query string, args ...interface{}) sql.Result
- func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
- func (t *Tx) PrepareContext(ctx context.Context, query string) IStmt
- func (t *Tx) PrepareSql(query string) IStmt
- func (t *Tx) Query(query string, args ...interface{}) *sql.Rows
- func (t *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows
- func (t *Tx) QueryOne(query string, args ...interface{}) IRow
- func (t *Tx) QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow
- func (t *Tx) Rollback() bool
Constants ¶
const ( DefaultMongoId = "mongo" ErrInvalidOpt = "mongo: invalid option " )
mongo
const ( DefaultMongodbId = "mongodb" ErrInvalidMongoDbOpt = "mongodb: invalid option " )
mongo
const ( DefaultDbTimeout = 10 * time.Second DefaultDbId = "db" )
db
const ( Reset = "\033[0m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" White = "\033[37m" BlueBold = "\033[34;1m" MagentaBold = "\033[35;1m" RedBold = "\033[31;1m" YellowBold = "\033[33;1m" )
Colors
const (
DefaultHttpId = "http"
)
http
const (
DefaultMaxMindId = "maxMind"
)
maxMind
const (
DefaultMemCacheId = "memCache"
)
memCache
const (
DefaultMemoryId = "memory"
)
memory
const (
DefaultOrmId = "orm"
)
orm
const (
DefaultRabbitId = "rabbitMq"
)
rabbitMq
const (
DefaultRedisId = "redis"
)
redis
Variables ¶
var DbClass string
var EsClass string
var HttpClass string
var MaxMindClass string
var MemCacheClass string
var MemoryClass string
var MongoClass string
var MongodbCAggregate string
var MongodbCQueryClass string
var MongodbClass string
var OrmClass string
var RabbitMqClass string
var RedisClass string
Functions ¶
func FileWithLineNum ¶ added in v0.1.134
func FileWithLineNum() string
func NewDbPool ¶
NewDbPool of db Client from pool, add context support. usage: db := this.GetObjPool(adapter.DbClass, adapter.NewDbPool).(adapter.IDb)/(*adapter.Db) It is recommended to use : db := this.GetObjBox(adapter.DbClass).(adapter.IDb)/(*adapter.Db)
func NewHttpPool ¶
Http of Http Client from pool, add context support. usage: http := this.GetObjPool(adapter.HttpClass, adapter.NewHttpPool).(adapter.IHttp)/(*adapter.Http) It is recommended to use : http := this.GetObjBox(adapter.HttpClass).(adapter.IHttp)/(*adapter.Http)
func NewMaxMindPool ¶
NewMaxMindPool of MaxMind Client from pool, add context support. usage: mmd := this.GetObjPool(adapter.MaxMindClass, adapter.NewMaxMindPool).(adapter.IMaxMind)/(*adapter.MaxMind) It is recommended to use :mmd := this.GetObjBox(adapter.MaxMindClass).(adapter.IMaxMind)/(*adapter.MaxMind)
func NewMemCachePool ¶
NewMemCachePool of MemCache Client from pool, add context support. usage: mc := this.GetObjPool(adapter.MemCacheClass, adapter.NewMemCachePool).(adapter.IMemCache)/(*adapter.MemCache) It is recommended to use :mc := this.GetObjBox(adapter.MemCacheClass).(adapter.IMemCache)/(*adapter.MemCache)
func NewMemoryPool ¶
NewMemoryPool of Memory Client from object pool, add context support. usage: memory := this.GetObjPool(adapter.MemoryClass, adapter.NewMemoryPool).(adapter.IMemory)/(*adapter.Memory) It is recommended to use : memory := this.GetObjBox(adapter.MemoryClass).(adapter.IMemory)/(*adapter.Memory)
func NewMongoPool ¶
NewMongoPool of Mongo Client from pool, add context support. usage: mongo := this.GetObjectPool(adapter.MongoClass, adapter.NewMongoPool,db, coll)).(adapter.IMongo)/(*adapter.Mongo) It is recommended to use : mongo := this.GetObjectBox(adapter.MongoClass,db, coll)).(adapter.IMongo)/(*adapter.Mongo)
func NewRabbitMqPool ¶
NewRabbitMqPool of RabbitMq Client from pool, add context support. usage: rabbitMq := this.GetObjPool(adapter.RabbitMqClass,adapter.NewRabbitMqPool).(adapter.IRabbitMq)/(*adapter.RabbitMq) It is recommended to use : rabbitMq := this.GetObjBox(adapter.RabbitMqClass).(adapter.IRabbitMq)/(*adapter.RabbitMq)
func NewRedisPool ¶
NewRedisPool of Redis Client from pool, add context support. usage: redis := this.GetObjPool(adapter.RedisClass, adapter.NewRedisPool).(*adapter.Redis) It is recommended to use : redis := this.GetObjBox(adapter.RedisClass).(*adapter.Redis)
Types ¶
type CAggregate ¶ added in v0.1.135
type CAggregate struct { pgo2.Object qmgo.AggregateI // contains filtered or unexported fields }
func (*CAggregate) All ¶ added in v0.1.135
func (c *CAggregate) All(results interface{}) error
func (*CAggregate) One ¶ added in v0.1.135
func (c *CAggregate) One(results interface{}) error
func (*CAggregate) Prepare ¶ added in v0.1.135
func (c *CAggregate) Prepare(q qmgo.AggregateI, dftCtxCancel ...context.CancelFunc)
type CQuery ¶ added in v0.1.134
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
func NewDb ¶
NewDb of db Client, add context support. usage: db := this.GetObj(adapter.NewDb()).(adapter.IDb)/(*adapter.Db)
func (*Db) Begin ¶
Begin start a transaction with default timeout context and optional opts, if opts is nil, default driver option will be used.
func (*Db) BeginContext ¶
BeginContext start a transaction with specified context and optional opts, if opts is nil, default driver option will be used.
func (*Db) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Db) Prepare ¶
func (d *Db) Prepare(componentId ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*Db) PrepareContext ¶
PrepareContext creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Db) PrepareSql ¶ added in v0.1.109
PrepareSql creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Db) QueryContext ¶
QueryContext perform query using a specified context.
func (*Db) QueryOne ¶
QueryOne perform one row query using a default timeout context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
func (*Db) QueryOneContext ¶
QueryOneContext perform one row query using a specified context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
type Es ¶ added in v0.1.140
Adapter of ElasticSearch Client, add context support. Adapter of Http Client, add context support. usage: http := this.GetObjBox(adapter.EsClass).(*adapter.Es)
func NewEs ¶ added in v0.1.140
NewEs of ElasticSearch Client, add context support. usage: es := this.GetObj(adapter.NewEs()).(adapter.IEs)/(*adapter.Es)
type Http ¶
func NewHttp ¶
Http of Http Client, add context support. usage: http := this.GetObj(adapter.NewHttp()).(adapter.IHttp)/(*adapter.Http)
func (*Http) Prepare ¶ added in v0.1.131
func (h *Http) Prepare(componentId ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*Http) SetPanicRecover ¶
type IDb ¶
type IDb interface { SetMaster(v bool) GetDb(master bool) *sql.DB Begin(opts ...*sql.TxOptions) ITx BeginContext(ctx context.Context, opts *sql.TxOptions) ITx QueryOne(query string, args ...interface{}) IRow QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow Query(query string, args ...interface{}) *sql.Rows QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows Exec(query string, args ...interface{}) sql.Result ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result PrepareSql(query string) IStmt PrepareContext(ctx context.Context, query string) IStmt }
type IHttp ¶
type IHttp interface { SetPanicRecover(v bool) Get(addr string, data interface{}, option ...*phttp.Option) *http.Response Post(addr string, data interface{}, option ...*phttp.Option) *http.Response Do(req *http.Request, option ...*phttp.Option) *http.Response DoMulti(requests []*http.Request, option ...*phttp.Option) []*http.Response }
type IMemCache ¶
type IMemCache interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int Retrieve(cmd, key string) *memcache.Item MultiRetrieve(cmd string, keys []string) []*memcache.Item Store(cmd string, item *memcache.Item, expire ...time.Duration) bool MultiStore(cmd string, items []*memcache.Item, expire ...time.Duration) bool }
type IMemory ¶
type IMemory interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int }
type IMongo ¶
type IMongo interface { FindOne(query interface{}, result interface{}, options ...bson.M) error FindAll(query interface{}, result interface{}, options ...bson.M) error FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error InsertOne(doc interface{}) error InsertAll(docs []interface{}) error UpdateOne(query interface{}, update interface{}) error UpdateAll(query interface{}, update interface{}) error UpdateOrInsert(query interface{}, update interface{}) error DeleteOne(query interface{}) error DeleteAll(query interface{}) error Count(query interface{}, options ...bson.M) (int, error) PipeOne(pipeline interface{}, result interface{}) error PipeAll(pipeline interface{}, result interface{}) error MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error }
type IMongodb ¶ added in v0.1.134
type IMongodb interface { iface.IObject Count(query interface{}) (int, error) FindAndModify(query interface{}, change qmgo.Change, result interface{}, options ...bson.M) error DeleteAll(query interface{}) error DeleteOne(query interface{}) error InsertAll(docs interface{}) error PipeAll(query interface{}, desc interface{}) error PipeOne(pipeline interface{}, result interface{}) error UpdateOrInsert(query interface{}, doc interface{}) error FindOne(query interface{}, doc interface{}, options ...bson.M) error FindAll(query interface{}, doc interface{}, options ...bson.M) error InsertOne(doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error) InsertOneCtx(ctx context.Context, doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error) InsertMany(docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error) InsertManyCtx(ctx context.Context, docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error) Upsert(filter interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error) UpsertCtx(ctx context.Context, filter interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error) UpsertId(id interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error) UpsertIdCtx(ctx context.Context, id interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error) UpdateOne(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (err error) UpdateOneCtx(ctx context.Context, filter interface{}, update interface{}, opts ...opts.UpdateOptions) (err error) UpdateId(id interface{}, update interface{}, opts ...opts.UpdateOptions) (err error) UpdateIdCtx(ctx context.Context, id interface{}, update interface{}, opts ...opts.UpdateOptions) (err error) UpdateAll(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (result *qmgo.UpdateResult, err error) UpdateAllCtx(ctx context.Context, filter interface{}, update interface{}, opts ...opts.UpdateOptions) (result *qmgo.UpdateResult, err error) ReplaceOne(filter interface{}, doc interface{}, opts ...opts.ReplaceOptions) (err error) ReplaceOneCtx(ctx context.Context, filter interface{}, doc interface{}, opts ...opts.ReplaceOptions) (err error) Remove(filter interface{}, opts ...opts.RemoveOptions) (err error) RemoveCtx(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (err error) RemoveId(id interface{}, opts ...opts.RemoveOptions) (err error) RemoveIdCtx(ctx context.Context, id interface{}, opts ...opts.RemoveOptions) (err error) RemoveAll(filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error) RemoveAllCtx(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error) Aggregate(pipeline interface{}) IMongodbAggregate AggregateCtx(ctx context.Context, pipeline interface{}) IMongodbAggregate EnsureIndexes(uniques []string, indexes []string) (err error) EnsureIndexesCtx(ctx context.Context, uniques []string, indexes []string) (err error) CreateIndexes(indexes []opts.IndexModel) (err error) CreateIndexesCtx(ctx context.Context, indexes []opts.IndexModel) (err error) CreateOneIndex(index opts.IndexModel) error CreateOneIndexCtx(ctx context.Context, index opts.IndexModel) (err error) DropAllIndexes() (err error) DropAllIndexesCtx(ctx context.Context) (err error) DropIndex(indexes []string) error DropIndexCtx(ctx context.Context, indexes []string) error DropCollection() error DropCollectionCtx(ctx context.Context) error CloneCollection() (*mongo.Collection, error) GetCollectionName() string Find(filter interface{}, options ...opts.FindOptions) IMongodbQuery FindCtx(ctx context.Context, filter interface{}, options ...opts.FindOptions) IMongodbQuery GetClient() *mongodb.Client Session() (*qmgo.Session, error) DoTransaction(ctx context.Context, callback func(sessCtx context.Context) (interface{}, error)) (interface{}, error) }
type IMongodbAggregate ¶ added in v0.1.135
type IMongodbAggregate interface { qmgo.AggregateI }
type IMongodbQuery ¶ added in v0.1.134
type IOrm ¶ added in v0.1.132
type IOrm interface { iface.IObject Assign(attrs ...interface{}) IOrm Attrs(attrs ...interface{}) IOrm Begin(opts ...*sql.TxOptions) IOrm Clauses(conds ...clause.Expression) IOrm Commit() IOrm Count(count *int64) IOrm Create(value interface{}) IOrm CreateInBatches(value interface{}, batchSize int) IOrm Debug() IOrm Delete(value interface{}, conds ...interface{}) IOrm Distinct(args ...interface{}) IOrm Exec(sql string, values ...interface{}) IOrm Find(dest interface{}, conds ...interface{}) IOrm FindInBatches(dest interface{}, batchSize int, fc func(pTx *gorm.DB, batch int) error) IOrm First(dest interface{}, conds ...interface{}) IOrm FirstOrCreate(dest interface{}, conds ...interface{}) IOrm FirstOrInit(dest interface{}, conds ...interface{}) IOrm Group(name string) IOrm Having(query interface{}, args ...interface{}) IOrm Joins(query string, args ...interface{}) IOrm Last(dest string, conds ...interface{}) IOrm Limit(limit int) IOrm Model(value interface{}) IOrm Not(query interface{}, args ...interface{}) IOrm Offset(offset int) IOrm Omit(columns ...string) IOrm Or(query interface{}, args ...interface{}) IOrm Order(value interface{}) IOrm Pluck(column string, dest interface{}) IOrm Preload(query string, args ...interface{}) IOrm Raw(sql string, values ...interface{}) IOrm Rollback() IOrm RollbackTo(name string) IOrm Row() *sql.Row Rows() (*sql.Rows, error) Save(value interface{}) IOrm SavePoint(name string) IOrm Scan(dest interface{}) IOrm Scopes(funcs ...func(*gorm.DB) *gorm.DB) IOrm Select(query interface{}, args ...interface{}) IOrm Session(config *gorm.Session) IOrm InstanceSet(key string, value interface{}) IOrm Set(key string, value interface{}) IOrm Table(name string, args ...interface{}) IOrm Take(dest interface{}, conds ...interface{}) IOrm Unscoped() IOrm Update(column string, value interface{}) IOrm UpdateColumn(column string, value interface{}) IOrm UpdateColumns(values interface{}) IOrm Updates(values interface{}) IOrm Where(query interface{}, args ...interface{}) IOrm WithContext(ctx context.Context) IOrm AddError(err error) error Association(column string) *gorm.Association AutoMigrate(dst ...interface{}) error SqlDB() (*sql.DB, error) Get(key string) (interface{}, bool) InstanceGet(key string) (interface{}, bool) ScanRows(rows *sql.Rows, dest interface{}) error SetupJoinTable(model interface{}, field string, joinTable interface{}) error Transaction(fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error) Use(plugin gorm.Plugin) (err error) GetError() error GetRowsAffected() int64 GetStatement() *gorm.Statement GetConfig() *gorm.Config }
type IRabbitMq ¶
type IRabbitMq interface { SetPanicRecover(v bool) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData) Publish(opCode string, data interface{}, dftOpUid ...string) bool PublishExchange(serviceName, exchangeName, exchangeType, opCode string, data interface{}, dftOpUid ...string) bool ChannelBox() *rabbitmq.ChannelBox GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery DecodeBody(d amqp.Delivery, ret interface{}) error DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders }
type IRedis ¶
type IRedis interface { SetPanicRecover(v bool) Get(key string) *value.Value MGet(keys []string) map[string]*value.Value Set(key string, value interface{}, expire ...time.Duration) bool MSet(items map[string]interface{}, expire ...time.Duration) bool Add(key string, value interface{}, expire ...time.Duration) bool MAdd(items map[string]interface{}, expire ...time.Duration) bool Del(key string) bool MDel(keys []string) bool Exists(key string) bool Incr(key string, delta int) int IncrBy(key string, delta int64) (int64, error) Do(cmd string, args ...interface{}) interface{} ExpireAt(key string, timestamp int64) bool Expire(key string, expire time.Duration) bool RPush(key string, values ...interface{}) bool LPush(key string, values ...interface{}) bool RPop(key string) *value.Value LPop(key string) *value.Value LLen(key string) int64 HDel(key string, fields ...interface{}) int64 HExists(key, field string) bool HSet(key string, fv ...interface{}) bool HGet(key, field string) *value.Value HGetAll(key string) map[string]*value.Value HMSet(key string, fv ...interface{}) bool HMGet(key string, fields ...interface{}) map[string]*value.Value HIncrBy(key, field string, delta int64) (int64, error) ZRange(key string, start, end int) []*value.Value ZRevRange(key string, start, end int) []*value.Value ZRangeWithScores(key string, start, end int) []*redis.ZV ZRevRangeWithScores(key string, start, end int) []*redis.ZV ZAdd(key string, members ...*redis.Z) int64 ZAddOpt(key string, opts []string, members ...*redis.Z) (int64, error) ZCard(key string) int64 ZRem(key string, members ...interface{}) int64 }
type IStmt ¶
type IStmt interface { iface.IObject Close() QueryOne(args ...interface{}) IRow QueryOneContext(ctx context.Context, args ...interface{}) IRow Query(args ...interface{}) *sql.Rows QueryContext(ctx context.Context, args ...interface{}) *sql.Rows Exec(args ...interface{}) sql.Result ExecContext(ctx context.Context, args ...interface{}) sql.Result }
type ITx ¶
type ITx interface { iface.IObject Commit() bool Rollback() bool QueryOne(query string, args ...interface{}) IRow QueryOneContext(ctx context.Context, query string, args ...interface{}) IRow Query(query string, args ...interface{}) *sql.Rows QueryContext(ctx context.Context, query string, args ...interface{}) *sql.Rows Exec(query string, args ...interface{}) sql.Result ExecContext(ctx context.Context, query string, args ...interface{}) sql.Result PrepareSql(query string) IStmt PrepareContext(ctx context.Context, query string) IStmt }
type MaxMind ¶
func NewMaxMind ¶
NewMaxMind of MaxMind Client, add context support. usage: mmd := this.GetObj(adapter.NewMaxMind()).(adapter.IMaxMind)/(*adapter.MaxMind)
type MemCache ¶
func NewMemCache ¶
NewMemCache of MemCache Client, add context support. usage: mc := this.GetObj(adapter.NewMemCache()).(adapter.IMemCache)/(*adapter.MemCache)
func (*MemCache) MultiRetrieve ¶
func (*MemCache) MultiStore ¶
func (*MemCache) Prepare ¶ added in v0.1.131
func (m *MemCache) Prepare(componentId ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*MemCache) SetPanicRecover ¶
type Memory ¶
func NewMemory ¶
NewMemory of Memory Client, add context support. usage: memory := this.GetObj(adapter.NewMemory()).(adapter.IMemory)/(*adapter.Memory)
func (*Memory) Prepare ¶ added in v0.1.131
func (m *Memory) Prepare(componentId ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*Memory) SetPanicRecover ¶
type Mongo ¶
func NewMongo ¶
NewMongo of Mongo Client, add context support. usage: mongo := this.GetObj(adapter.NewMongo(db, coll)).(adapter.IMongo)/(*adapter.Mongo)
func (*Mongo) FindAll ¶
FindAll retrieve all documents that match the query, param result must be a slice(interface{}, map, bson.M or bson compatible struct) other params see FindOne()
func (*Mongo) FindAndModify ¶
func (m *Mongo) FindAndModify(query interface{}, change mgo.Change, result interface{}, options ...bson.M) error
FindAndModify execute findAndModify command, which allows atomically update or remove one document, param change specify the change operation, eg. mgo.Change{Update:bson.M{"$inc": bson.M{"n":1}}, ReturnNew:true}, other params see FindOne()
func (*Mongo) FindDistinct ¶
func (m *Mongo) FindDistinct(query interface{}, key string, result interface{}, options ...bson.M) error
FindDistinct retrieve distinct values for the param key, param result must be a slice, other params see FindOne()
func (*Mongo) FindOne ¶
FindOne retrieve the first document that match the query, query can be a map or bson compatible struct, such as bson.M or properly typed map, nil query is equivalent to empty query such as bson.M{}. result is pointer to interface{}, map, bson.M or bson compatible struct, if interface{} type is provided, the output result is a bson.M. options provided optional query option listed as follows: fields: bson.M, set output fields, eg. bson.M{"_id":0, "name":1}, sort: string or []string, set sort order, eg. "key1" or []string{"key1", "-key2"}, skip: int, set skip number, eg. 100, limit: int, set result limit, eg. 1, hint: string or []string, set index hint, eg. []string{"key1", "key2"}
for example:
var v1 interface{} // type of output v1 is bson.M m.FindOne(bson.M{"_id":"k1"}, &v1) var v2 struct { Id string `bson:"_id"` Name string `bson:"name"` Value string `bson:"value"` } m.FindOne(bson.M{"_id": "k1"}, &v2)
func (*Mongo) InsertAll ¶
InsertAll insert all documents provided by params docs into collection, for example:
docs := []interface{}{ bson.M{"_id":1, "name":"v1"}, bson.M{"_id":2, "name":"v2"}, } m.InsertAll(docs)
func (*Mongo) InsertOne ¶
InsertOne insert one document into collection, param doc can be a map, bson.M, bson compatible struct, for example:
m.InsertOne(bson.M{"field1":"value1", "field2":"value2"}) doc := struct { Field1 string `bson:"field1"` Field2 string `bson:"field2"` } {"value1", "value2"} m.InsertOne(doc)
func (*Mongo) MapReduce ¶
func (m *Mongo) MapReduce(query interface{}, job *mgo.MapReduce, result interface{}, options ...bson.M) error
MapReduce execute map/reduce job that match the query. param result is a slice(interface{}, map, bson.M, bson compatible struct), param query and options see FindOne(). for example:
job := &mgo.MapReduce{ Map: "function() { emit(this.n, 1) }", Reduce: "function(key, values) { return Array.sum(values) }", } result := []bson.M{} m.MapReduce(query, job, &result)
func (*Mongo) PipeAll ¶
PipeAll execute aggregation queries and get all item from result set. param result must be slice(interface{}, map, bson.M or bson compatible struct). see PipeOne().
func (*Mongo) PipeOne ¶
PipeOne execute aggregation queries and get the first item from result set. param pipeline must be a slice, such as []bson.M, param result is a pointer to interface{}, map, bson.M or bson compatible struct. for example:
pipeline := []bson.M{ bson.M{"$match": bson.M{"status":"A"}}, bson.M{"$group": bson.M{"_id":"$field1", "total":"$field2"}}, } m.PipeOne(pipeline, &result)
func (*Mongo) Prepare ¶ added in v0.1.131
func (m *Mongo) Prepare(args ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*Mongo) UpdateOne ¶
UpdateOne update one document that match the query, mgo.ErrNotFound is returned if a document not found, a value of *LastError is returned if other error occurred.
func (*Mongo) UpdateOrInsert ¶
UpdateOrInsert update a existing document that match the query, or insert a new document base on the update document if no document match, an error of *LastError is returned if error is detected.
type Mongodb ¶ added in v0.1.134
type Mongodb struct { pgo2.Object *qmgo.Collection // contains filtered or unexported fields }
func NewMongodb ¶ added in v0.1.134
NewMongodb of Mongodb Client, add context support. usage: Mongodb := this.GetObj(adapter.NewMongodb(db, coll)).(adapter.IMongodb)/(*adapter.Mongodb)
func (*Mongodb) Aggregate ¶ added in v0.1.134
func (m *Mongodb) Aggregate(pipeline interface{}) IMongodbAggregate
Aggregate executes an aggregate command against the collection and returns a AggregateI to get resulting documents.
func (*Mongodb) AggregateCtx ¶ added in v0.1.134
func (m *Mongodb) AggregateCtx(ctx context.Context, pipeline interface{}) IMongodbAggregate
func (*Mongodb) CloneCollection ¶ added in v0.1.134
func (m *Mongodb) CloneCollection() (*mongo.Collection, error)
func (*Mongodb) CreateIndexes ¶ added in v0.1.134
func (m *Mongodb) CreateIndexes(indexes []opts.IndexModel) (err error)
CreateIndexes creates multiple indexes in collection If the Key in opts.IndexModel is []string{"name"}, means create index: name If the Key in opts.IndexModel is []string{"name","-age"} means create Compound indexes: name and -age
func (*Mongodb) CreateIndexesCtx ¶ added in v0.1.134
func (*Mongodb) CreateOneIndex ¶ added in v0.1.134
func (m *Mongodb) CreateOneIndex(index opts.IndexModel) error
CreateOneIndex creates one index If the Key in opts.IndexModel is []string{"name"}, means create index name If the Key in opts.IndexModel is []string{"name","-age"} means create Compound index: name and -age
func (*Mongodb) CreateOneIndexCtx ¶ added in v0.1.134
func (*Mongodb) DoTransaction ¶ added in v0.1.134
func (*Mongodb) DropAllIndexes ¶ added in v0.1.134
DropAllIndexes drop all indexes on the collection except the index on the _id field if there is only _id field index on the collection, the function call will report an error
func (*Mongodb) DropAllIndexesCtx ¶ added in v0.1.134
func (*Mongodb) DropCollection ¶ added in v0.1.134
DropCollection drops collection it's safe even collection is not exists
func (*Mongodb) DropCollectionCtx ¶ added in v0.1.134
func (*Mongodb) DropIndex ¶ added in v0.1.134
DropIndex drop indexes in collection, indexes that be dropped should be in line with inputting indexes The indexes is []string{"name"} means drop index: name The indexes is []string{"name","-age"} means drop Compound indexes: name and -age
func (*Mongodb) DropIndexCtx ¶ added in v0.1.134
func (*Mongodb) EnsureIndexes ¶ added in v0.1.134
EnsureIndexes Deprecated Recommend to use CreateIndexes / CreateOneIndex for more function) EnsureIndexes creates unique and non-unique indexes in collection the combination of indexes is different from CreateIndexes: if uniques/indexes is []string{"name"}, means create index "name" if uniques/indexes is []string{"name,-age","uid"} means create Compound indexes: name and -age, then create one index: uid
func (*Mongodb) EnsureIndexesCtx ¶ added in v0.1.134
func (*Mongodb) Find ¶ added in v0.1.134
func (m *Mongodb) Find(filter interface{}, options ...opts.FindOptions) IMongodbQuery
func (*Mongodb) FindAndModify ¶ added in v0.1.142
func (m *Mongodb) FindAndModify(query interface{}, change qmgo.Change, result interface{}, options ...bson.M) error
FindAndModify execute findAndModify command, which allows atomically update or remove one document, param change specify the change operation, eg. mgo.Change{Update:bson.M{"$inc": bson.M{"n":1}}, ReturnNew:true}, other params see FindOne()
func (*Mongodb) FindCtx ¶ added in v0.1.134
func (m *Mongodb) FindCtx(ctx context.Context, filter interface{}, options ...opts.FindOptions) IMongodbQuery
func (*Mongodb) GetCollectionName ¶ added in v0.1.134
func (*Mongodb) InsertMany ¶ added in v0.1.134
func (m *Mongodb) InsertMany(docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error)
InsertMany executes an insert command to insert multiple documents into the collection. If InsertHook in opts is set, hook works on it, otherwise hook try the doc as hook Reference: https://docs.mongodb.com/manual/reference/command/insert/
func (*Mongodb) InsertManyCtx ¶ added in v0.1.134
func (m *Mongodb) InsertManyCtx(ctx context.Context, docs interface{}, opts ...opts.InsertManyOptions) (result *qmgo.InsertManyResult, err error)
func (*Mongodb) InsertOne ¶ added in v0.1.134
func (m *Mongodb) InsertOne(doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error)
InsertOne insert one document into the collection If InsertHook in opts is set, hook works on it, otherwise hook try the doc as hook Reference: https://docs.mongodb.com/manual/reference/command/insert/
func (*Mongodb) InsertOneCtx ¶ added in v0.1.134
func (m *Mongodb) InsertOneCtx(ctx context.Context, doc interface{}, opts ...opts.InsertOneOptions) (result *qmgo.InsertOneResult, err error)
func (*Mongodb) PipeOne ¶ added in v0.1.143
PipeOne execute aggregation queries and get the first item from result set. param pipeline must be a slice, such as []bson.M, param result is a pointer to interface{}, map, bson.M or bson compatible struct. for example:
pipeline := []bson.M{ bson.M{"$match": bson.M{"status":"A"}}, bson.M{"$group": bson.M{"_id":"$field1", "total":"$field2"}}, } m.PipeOne(pipeline, &result)
func (*Mongodb) Remove ¶ added in v0.1.134
func (m *Mongodb) Remove(filter interface{}, opts ...opts.RemoveOptions) (err error)
Remove executes a delete command to delete at most one document from the collection. if filter is bson.M{},DeleteOne will delete one document in collection Reference: https://docs.mongodb.com/manual/reference/command/delete/
func (*Mongodb) RemoveAll ¶ added in v0.1.134
func (m *Mongodb) RemoveAll(filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error)
func (*Mongodb) RemoveAllCtx ¶ added in v0.1.134
func (m *Mongodb) RemoveAllCtx(ctx context.Context, filter interface{}, opts ...opts.RemoveOptions) (result *qmgo.DeleteResult, err error)
func (*Mongodb) RemoveId ¶ added in v0.1.134
func (m *Mongodb) RemoveId(id interface{}, opts ...opts.RemoveOptions) (err error)
RemoveId executes a delete command to delete at most one document from the collection.
func (*Mongodb) RemoveIdCtx ¶ added in v0.1.134
func (*Mongodb) ReplaceOne ¶ added in v0.1.134
func (m *Mongodb) ReplaceOne(filter interface{}, doc interface{}, opts ...opts.ReplaceOptions) (err error)
ReplaceOne executes an update command to update at most one document in the collection. If UpdateHook in opts is set, hook works on it, otherwise hook try the doc as hook Expect type of the doc is the define of user's document
func (*Mongodb) ReplaceOneCtx ¶ added in v0.1.134
func (*Mongodb) UpdateAll ¶ added in v0.1.134
func (m *Mongodb) UpdateAll(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (result *qmgo.UpdateResult, err error)
UpdateAll executes an update command to update documents in the collection. The matchedCount is 0 in UpdateResult if no document updated Reference: https://docs.mongodb.com/manual/reference/operator/update/
func (*Mongodb) UpdateAllCtx ¶ added in v0.1.134
func (m *Mongodb) UpdateAllCtx(ctx context.Context, filter interface{}, update interface{}, opts ...opts.UpdateOptions) (result *qmgo.UpdateResult, err error)
func (*Mongodb) UpdateId ¶ added in v0.1.134
func (m *Mongodb) UpdateId(id interface{}, update interface{}, opts ...opts.UpdateOptions) (err error)
UpdateId executes an update command to update at most one document in the collection. Reference: https://docs.mongodb.com/manual/reference/operator/update/
func (*Mongodb) UpdateIdCtx ¶ added in v0.1.134
func (*Mongodb) UpdateOne ¶ added in v0.1.134
func (m *Mongodb) UpdateOne(filter interface{}, update interface{}, opts ...opts.UpdateOptions) (err error)
UpdateOne executes an update command to update at most one document in the collection. Reference: https://docs.mongodb.com/manual/reference/operator/update/
func (*Mongodb) UpdateOneCtx ¶ added in v0.1.134
func (*Mongodb) UpdateOrInsert ¶ added in v0.1.141
func (*Mongodb) Upsert ¶ added in v0.1.134
func (m *Mongodb) Upsert(filter interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
Upsert updates one documents if filter match, inserts one document if filter is not match, Error when the filter is invalid The replacement parameter must be a document that will be used to replace the selected document. It cannot be nil and cannot contain any update operators Reference: https://docs.mongodb.com/manual/reference/operator/update/ If replacement has "_id" field and the document is exist, please initial it with existing id(even with Qmgo default field feature). Otherwise "the (immutable) field '_id' altered" error happens.
func (*Mongodb) UpsertCtx ¶ added in v0.1.134
func (m *Mongodb) UpsertCtx(ctx context.Context, filter interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
func (*Mongodb) UpsertId ¶ added in v0.1.134
func (m *Mongodb) UpsertId(id interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
UpsertId updates one documents if id match, inserts one document if id is not match and the id will inject into the document The replacement parameter must be a document that will be used to replace the selected document. It cannot be nil and cannot contain any update operators Reference: https://docs.mongodb.com/manual/reference/operator/update/
func (*Mongodb) UpsertIdCtx ¶ added in v0.1.134
func (m *Mongodb) UpsertIdCtx(ctx context.Context, id interface{}, replacement interface{}, opts ...opts.UpsertOptions) (result *qmgo.UpdateResult, err error)
type Orm ¶ added in v0.1.132
func NewOrm ¶ added in v0.1.132
NewDb of db Client, add context support. usage: db := this.GetObj(adapter.NewOrm(ctr)).(*adapter.Orm/adapter.IOrm)
func (*Orm) CreateInBatches ¶ added in v0.1.132
func (*Orm) FindInBatches ¶ added in v0.1.132
func (*Orm) FirstOrCreate ¶ added in v0.1.132
func (*Orm) FirstOrInit ¶ added in v0.1.132
func (*Orm) GetRowsAffected ¶ added in v0.1.132
func (*Orm) GetStatement ¶ added in v0.1.132
func (*Orm) InstanceSet ¶ added in v0.1.132
func (*Orm) Prepare ¶ added in v0.1.132
func (o *Orm) Prepare(componentId ...interface{})
NewDb of db Client, add context support. usage: db := this.GetObjBox(adapter.OrmClass).(*adapter.Orm/adapter.IOrm)
func (*Orm) RollbackTo ¶ added in v0.1.132
func (*Orm) UpdateColumn ¶ added in v0.1.132
func (*Orm) UpdateColumns ¶ added in v0.1.132
type RabbitMq ¶
func NewRabbitMq ¶
NewRabbitMq of RabbitMq Client, add context support. usage: rabbitMq := this.GetObj(adapter.NewRabbitMq()).(adapter.IRabbitMq)/(*adapter.RabbitMq)
func (*RabbitMq) ChannelBox ¶ added in v0.1.103
func (r *RabbitMq) ChannelBox() *rabbitmq.ChannelBox
func (*RabbitMq) Consume ¶
func (r *RabbitMq) Consume(queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
消费,返回chan 可以不停取数据 queueName 队列名字 opCodes 绑定队列的code limit 每次接收多少条 autoAck 是否自动答复 如果为false 需要手动调用Delivery.ack(false) noWait 是否一直等待 exclusive 是否独占队列
func (*RabbitMq) ConsumeExchange ¶ added in v0.1.99
func (r *RabbitMq) ConsumeExchange(exchangeName, exchangeType, queueName string, opCodes []string, limit int, autoAck, noWait, exclusive bool) <-chan amqp.Delivery
消费,返回chan 可以不停取数据 exchangeName 交换机名 exchangeType 交换机type queueName 队列名字 opCodes 绑定队列的code limit 每次接收多少条 autoAck 是否自动答复 如果为false 需要手动调用Delivery.ack(false) noWait 是否一直等待 exclusive 是否独占队列
func (*RabbitMq) DecodeHeaders ¶
func (r *RabbitMq) DecodeHeaders(d amqp.Delivery) *rabbitmq.RabbitHeaders
func (*RabbitMq) ExchangeDeclare ¶
func (r *RabbitMq) ExchangeDeclare(dftExchange ...*rabbitmq.ExchangeData)
func (*RabbitMq) GetConsumeChannelBox ¶
func (r *RabbitMq) GetConsumeChannelBox(queueName string, opCodes []string, dftExchange ...*rabbitmq.ExchangeData) *rabbitmq.ChannelBox
func (*RabbitMq) Prepare ¶ added in v0.1.131
func (r *RabbitMq) Prepare(dftConfig ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*RabbitMq) PublishExchange ¶ added in v0.1.99
func (*RabbitMq) PublishExchangeDelivery ¶ added in v0.1.118
func (*RabbitMq) SetPanicRecover ¶
type Redis ¶
func NewRedis ¶
NewRedis of Redis Client, add context support. usage: redis := this.GetObject(adapter.NewRedis()).(*adapter.Redis)
func (*Redis) Do ¶
支持的命令请查阅:Redis.allRedisCmd args = [0:"key"] Example: redis := t.GetObjBox(Redis.AdapterClass).(*Redis.Adapter) retI := redis.Do("SADD","myTest", "test1" ret := retI.(int64) fmt.Println(ret) = 1 retList :=redis.Do("SMEMBERS","myTest" retListI,_:=ret.([]interface{})
for _,v:=range retListI{ vv :=value.New(v) // 写入的时候有value.Encode(),如果存入的是结构体或slice map 需要decode,其他类型直接断言类型 fmt.Println(vv.String()) // test1 }
func (*Redis) Prepare ¶ added in v0.1.131
func (r *Redis) Prepare(componentId ...interface{})
GetObjPool, GetObjBox fetch is performed automatically
func (*Redis) SetPanicRecover ¶
func (*Redis) ZRangeWithScores ¶ added in v0.1.137
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt wrap sql.Stmt, add context support
func (*Stmt) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Stmt) QueryContext ¶
QueryContext perform query using a specified context.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx wrapper for sql.Tx
func (*Tx) ExecContext ¶
ExecContext perform exec using a specified context.
func (*Tx) PrepareContext ¶
PrepareContext creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Tx) PrepareSql ¶ added in v0.1.109
PrepareSql creates a prepared statement for later queries or executions, the Close method must be called by caller.
func (*Tx) QueryContext ¶
QueryContext perform query using a specified context.
func (*Tx) QueryOne ¶
QueryOne perform one row query using a default timeout context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.
func (*Tx) QueryOneContext ¶
QueryOneContext perform one row query using a specified context, and always returns a non-nil value, Errors are deferred until Row's Scan method is called.