Documentation ¶
Index ¶
- Constants
- Variables
- func Any(a any) any
- func Bool(b bool) bool
- func Float32(f float32) float32
- func Float64(f float64) float64
- func Int(i int) int
- func Int16(i int16) int16
- func Int32(i int32) int32
- func Int64(i int64) int64
- func Int8(i int8) int8
- func JsonDecodeNoError(b []byte) map[string]interface{}
- func JsonEncodeNoError(data interface{}) string
- func String(s string) string
- func Uint(ui uint) uint
- func Uint16(ui uint16) uint16
- func Uint32(ui uint32) uint32
- func Uint64(ui uint64) uint64
- func Uint8(ui uint8) uint8
- func XmlDecodeNoError(b []byte) map[string]interface{}
- func XmlEncodeNoError(data interface{}) string
- type BsonTime
- func (bt BsonTime) Format() string
- func (bt BsonTime) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (bt BsonTime) MarshalJSON() ([]byte, error)
- func (bt BsonTime) Time() time.Time
- func (bt BsonTime) TimePro() gotime.Pro
- func (bt *BsonTime) UnmarshalBSONValue(t bsontype.Type, data []byte) error
- func (bt *BsonTime) UnmarshalJSON(data []byte) (err error)
- func (bt BsonTime) Value() string
- type DBGttFunc
- type DBGttInterfaceFunc
- type DBGttJsonFunc
- type DBGttStringFunc
- type GormClient
- type GormClientConfig
- type GormClientFun
- type GormClientTableFun
- type GttInterfaceFunc
- type GttStringFunc
- type HashOperation
- type Iterator
- type JsonGttFunc
- type ListOperation
- func (cl *ListOperation) Index(key string, index int64) *redis.StringCmd
- func (cl *ListOperation) Insert(key, op string, pivot, value interface{}) *redis.IntCmd
- func (cl *ListOperation) LPop(key string) *redis.StringCmd
- func (cl *ListOperation) LPush(key string, value interface{}) *redis.IntCmd
- func (cl *ListOperation) LPushX(key string, value interface{}) *redis.IntCmd
- func (cl *ListOperation) Len(key string) *redis.IntCmd
- func (cl *ListOperation) RPop(key string) *redis.StringCmd
- func (cl *ListOperation) RPush(key string, value interface{}) *redis.IntCmd
- func (cl *ListOperation) RPushX(key string, value interface{}) *redis.IntCmd
- func (cl *ListOperation) Range(key string, start, stop int64) *redis.StringSliceCmd
- func (cl *ListOperation) RangeAli(key string) *redis.StringSliceCmd
- func (cl *ListOperation) Rem(key string, count int64, value interface{}) *redis.IntCmd
- type MongoClient
- func (c *MongoClient) Begin() *MongoSessionOptions
- func (c *MongoClient) Close(ctx context.Context) error
- func (c *MongoClient) Database(name string, opts ...*options.DatabaseOptions) *MongoDatabaseOptions
- func (c *MongoClient) GetDb() *mongo.Client
- func (c *MongoClient) Model(value interface{}) *MongoCollectionOptions
- type MongoClientCollectionFun
- type MongoClientConfig
- type MongoClientFun
- type MongoCollectionOptions
- func (cc *MongoCollectionOptions) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
- func (cc *MongoCollectionOptions) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (cc *MongoCollectionOptions) CreateManyIndexes(ctx context.Context, models []mongo.IndexModel) ([]string, error)
- func (cc *MongoCollectionOptions) CreateOneIndexes(ctx context.Context, key string, value string) (string, error)
- func (cc *MongoCollectionOptions) CreateOneUniqueIndexes(ctx context.Context, key string, value string) (string, error)
- func (cc *MongoCollectionOptions) CreateOneUniqueIndexesOpts(ctx context.Context, key string, value string, opts *options.IndexOptions) (string, error)
- func (cc *MongoCollectionOptions) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (cc *MongoCollectionOptions) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (cc *MongoCollectionOptions) Distinct(ctx context.Context, fieldName string, filter interface{}, ...) ([]interface{}, error)
- func (cc *MongoCollectionOptions) Drop(ctx context.Context) error
- func (cc *MongoCollectionOptions) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)
- func (cc *MongoCollectionOptions) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (cc *MongoCollectionOptions) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (cc *MongoCollectionOptions) FindOneAndDelete(ctx context.Context, filter interface{}, ...) *mongo.SingleResult
- func (cc *MongoCollectionOptions) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, ...) *mongo.SingleResult
- func (cc *MongoCollectionOptions) FindOneAndUpdate(ctx context.Context, filter interface{}, replacement interface{}, ...) *mongo.SingleResult
- func (cc *MongoCollectionOptions) Indexes(ctx context.Context) mongo.IndexView
- func (cc *MongoCollectionOptions) InsertMany(ctx context.Context, document []interface{}, ...) (*mongo.InsertManyResult, error)
- func (cc *MongoCollectionOptions) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (cc *MongoCollectionOptions) ReplaceOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (cc *MongoCollectionOptions) UpdateByID(ctx context.Context, id interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (cc *MongoCollectionOptions) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (cc *MongoCollectionOptions) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (cc *MongoCollectionOptions) Watch(ctx context.Context, pipeline interface{}, ...) (*mongo.ChangeStream, error)
- type MongoDatabaseOptions
- func (cd *MongoDatabaseOptions) Collection(name string, opts ...*options.CollectionOptions) *MongoCollectionOptions
- func (cd *MongoDatabaseOptions) CreateCollection(ctx context.Context, name string, opts ...*options.CreateCollectionOptions) error
- func (cd *MongoDatabaseOptions) CreateTimeSeriesCollection(ctx context.Context, name string, timeField string) error
- type MongoSessionCollectionOptions
- func (csc *MongoSessionCollectionOptions) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
- func (csc *MongoSessionCollectionOptions) CountDocuments(filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (csc *MongoSessionCollectionOptions) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (csc *MongoSessionCollectionOptions) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (csc *MongoSessionCollectionOptions) Distinct(fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
- func (csc *MongoSessionCollectionOptions) Drop() error
- func (csc *MongoSessionCollectionOptions) EstimatedDocumentCount(opts ...*options.EstimatedDocumentCountOptions) (int64, error)
- func (csc *MongoSessionCollectionOptions) Find(filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (csc *MongoSessionCollectionOptions) FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (csc *MongoSessionCollectionOptions) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
- func (csc *MongoSessionCollectionOptions) FindOneAndReplace(filter interface{}, replacement interface{}, ...) *mongo.SingleResult
- func (csc *MongoSessionCollectionOptions) FindOneAndUpdate(filter interface{}, replacement interface{}, ...) *mongo.SingleResult
- func (csc *MongoSessionCollectionOptions) Indexes() mongo.IndexView
- func (csc *MongoSessionCollectionOptions) InsertMany(document []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
- func (csc *MongoSessionCollectionOptions) InsertOne(document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (csc *MongoSessionCollectionOptions) ReplaceOne(filter interface{}, update interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
- func (csc *MongoSessionCollectionOptions) UpdateByID(id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (csc *MongoSessionCollectionOptions) UpdateMany(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (csc *MongoSessionCollectionOptions) UpdateOne(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- func (csc *MongoSessionCollectionOptions) Watch(pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
- type MongoSessionDatabaseOptions
- type MongoSessionOptions
- func (cs *MongoSessionOptions) Commit()
- func (cs *MongoSessionOptions) Database(name string, opts ...*options.DatabaseOptions) *MongoSessionDatabaseOptions
- func (cs *MongoSessionOptions) GetDb() *mongo.Client
- func (cs *MongoSessionOptions) GetSession() mongo.Session
- func (cs *MongoSessionOptions) GetSessionContext() mongo.SessionContext
- func (cs *MongoSessionOptions) Model(value interface{}) *MongoSessionCollectionOptions
- func (cs *MongoSessionOptions) Rollback()
- type OperationAttr
- type OperationAttrs
- type RedisCacheConfig
- type RedisClient
- func (r *RedisClient) Decr(ctx context.Context, key string) *redis.IntCmd
- func (r *RedisClient) DecrBy(ctx context.Context, key string, value int64) *redis.IntCmd
- func (r *RedisClient) Del(ctx context.Context, keys ...string) *redis.IntCmd
- func (r *RedisClient) Get(ctx context.Context, key string) *redis.StringCmd
- func (r *RedisClient) GetDb() *redis.Client
- func (r *RedisClient) GetSet(ctx context.Context, key string, value interface{}) *redis.StringCmd
- func (r *RedisClient) Incr(ctx context.Context, key string) *redis.IntCmd
- func (r *RedisClient) IncrBy(ctx context.Context, key string, value int64) *redis.IntCmd
- func (r *RedisClient) Keys(ctx context.Context, prefix string) []string
- func (r *RedisClient) KeysValue(ctx context.Context, prefix string) *redis.SliceCmd
- func (r *RedisClient) MGet(ctx context.Context, keys ...string) *redis.SliceCmd
- func (r *RedisClient) MSet(ctx context.Context, values map[string]interface{}) *redis.StatusCmd
- func (r *RedisClient) NewCache(config *RedisCacheConfig) *RedisClientCache
- func (r *RedisClient) NewCacheDefaultExpiration() *RedisClientCache
- func (r *RedisClient) NewListOperation() *ListOperation
- func (r *RedisClient) NewLock() *RedisClientLock
- func (r *RedisClient) NewSimpleCache(operation *StringOperation, expire time.Duration, serializer string) *SimpleCache
- func (r *RedisClient) NewSimpleInterfaceCache(operation *SimpleOperation, expire time.Duration) *SimpleInterfaceCache
- func (r *RedisClient) NewSimpleJsonCache(operation *StringOperation, expire time.Duration) *SimpleJsonCache
- func (r *RedisClient) NewSimpleOperation() *SimpleOperation
- func (r *RedisClient) NewSimpleStringCache(operation *StringOperation, expire time.Duration) *SimpleStringCache
- func (r *RedisClient) NewStringOperation() *StringOperation
- func (r *RedisClient) PSubscribe(ctx context.Context, channels ...string) *redis.PubSub
- func (r *RedisClient) PubSubChannels(ctx context.Context, pattern string) *redis.StringSliceCmd
- func (r *RedisClient) PubSubNumSub(ctx context.Context, channels ...string) *redis.MapStringIntCmd
- func (r *RedisClient) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd
- func (r *RedisClient) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
- func (r *RedisClient) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd
- func (r *RedisClient) Subscribe(ctx context.Context, channels ...string) *redis.PubSub
- type RedisClientCache
- func (rc *RedisClientCache) GetInterface(ctx context.Context, key string, result interface{})
- func (rc *RedisClientCache) GetInterfaceKey(ctx context.Context, key string, result interface{}) error
- func (rc *RedisClientCache) GetString(ctx context.Context, key string) (ret string)
- func (rc *RedisClientCache) SetInterfaceKey(ctx context.Context, key string, value interface{}) (string, error)
- type RedisClientConfig
- type RedisClientFun
- type RedisClientLock
- func (rl *RedisClientLock) Lock(ctx context.Context, key string, val string, ttl time.Duration) (resp string, err error)
- func (rl *RedisClientLock) LockForever(ctx context.Context, key string, val string) (resp string, err error)
- func (rl *RedisClientLock) Unlock(ctx context.Context, key string) error
- type SimpleCache
- type SimpleInterfaceCache
- type SimpleJsonCache
- type SimpleOperation
- type SimpleResult
- type SimpleStringCache
- type SliceResult
- type StringOperation
- func (o *StringOperation) Del(ctx context.Context, keys ...string) *redis.IntCmd
- func (o *StringOperation) Get(ctx context.Context, key string) *StringResult
- func (o *StringOperation) MGet(ctx context.Context, keys ...string) *SliceResult
- func (o *StringOperation) Set(ctx context.Context, key string, value interface{}, attrs ...*OperationAttr) *StringResult
- type StringResult
- type XormClient
- type XormClientConfigXorm
- type XormClientSession
Constants ¶
const ( AttrExpr = "expr" // 过期时间 AttrNx = "nx" // 设置Nx )
const ( SerializerJson = "json" SerializerString = "string" )
Variables ¶
var ( NoConfigDatabaseName = errors.New("没有配置库名") NoConfigCollectionName = errors.New("没有配置集合名") )
var ( // GormNotFound 没有数据 GormNotFound = gorm.ErrRecordNotFound )
var ( // RedisKeysNotFound keys没有数据 RedisKeysNotFound = errors.New("ERR wrong number of arguments for 'mget' command") )
Functions ¶
func JsonDecodeNoError ¶
JsonDecodeNoError json字符串转结构体,不报错
func JsonEncodeNoError ¶ added in v1.0.52
func JsonEncodeNoError(data interface{}) string
JsonEncodeNoError 结构体转json字符串,不报错
func XmlDecodeNoError ¶
XmlDecodeNoError xml字符串转结构体,不报错
func XmlEncodeNoError ¶ added in v1.0.52
func XmlEncodeNoError(data interface{}) string
XmlEncodeNoError 结构体转json字符串,不报错
Types ¶
type BsonTime ¶
BsonTime 时间类型
func NewBsonTimeCurrent ¶ added in v1.0.52
func NewBsonTimeCurrent() BsonTime
NewBsonTimeCurrent 创建当前时间
func NewBsonTimeFromString ¶ added in v1.0.52
NewBsonTimeFromString 创建某个时间 字符串
func NewBsonTimeFromTime ¶ added in v1.0.52
NewBsonTimeFromTime 创建某个时间
func (BsonTime) MarshalBSONValue ¶
MarshalBSONValue 实现bson序列化
func (BsonTime) MarshalJSON ¶
MarshalJSON 实现json序列化
func (*BsonTime) UnmarshalBSONValue ¶
UnmarshalBSONValue 实现bson反序列化
func (*BsonTime) UnmarshalJSON ¶
UnmarshalJSON 实现json反序列化
type DBGttInterfaceFunc ¶
type DBGttInterfaceFunc func() interface{}
type DBGttJsonFunc ¶
type DBGttJsonFunc func() interface{}
type DBGttStringFunc ¶
type DBGttStringFunc func() string
type GormClient ¶
GormClient https://gorm.io/
func NewGormMysqlClient ¶
func NewGormMysqlClient(config *GormClientConfig) (*GormClient, error)
func NewGormPostgresClient ¶
func NewGormPostgresClient(config *GormClientConfig) (*GormClient, error)
func NewGormPostgresqlClient ¶
func NewGormPostgresqlClient(config *GormClientConfig) (*GormClient, error)
type GormClientConfig ¶ added in v1.0.52
type GormClientFun ¶ added in v1.0.52
type GormClientFun func() *GormClient
GormClientFun *GormClient 驱动
type GormClientTableFun ¶ added in v1.0.52
type GormClientTableFun func() (*GormClient, string)
GormClientTableFun *GormClient 驱动 string 表名
type GttInterfaceFunc ¶ added in v1.0.51
type GttInterfaceFunc func() interface{}
GttInterfaceFunc Interface缓存结构
type HashOperation ¶
type HashOperation struct {
// contains filtered or unexported fields
}
func NewHashOperation ¶
func NewHashOperation(db *redis.Client) *HashOperation
NewHashOperation hash类型数据操作 https://www.tizi365.com/archives/296.html
type JsonGttFunc ¶
type JsonGttFunc func() interface{}
type ListOperation ¶
type ListOperation struct {
// contains filtered or unexported fields
}
func (*ListOperation) Index ¶
func (cl *ListOperation) Index(key string, index int64) *redis.StringCmd
Index 根据索引坐标,查询key中的数据
func (*ListOperation) Insert ¶
func (cl *ListOperation) Insert(key, op string, pivot, value interface{}) *redis.IntCmd
Insert 在指定位置插入数据
func (*ListOperation) LPop ¶
func (cl *ListOperation) LPop(key string) *redis.StringCmd
LPop 从列表左边删除第一个数据,并返回删除的数据
func (*ListOperation) LPush ¶
func (cl *ListOperation) LPush(key string, value interface{}) *redis.IntCmd
LPush 从列表左边插入数据
func (*ListOperation) LPushX ¶
func (cl *ListOperation) LPushX(key string, value interface{}) *redis.IntCmd
LPushX 跟LPush的区别是,仅当列表存在的时候才插入数据
func (*ListOperation) RPop ¶
func (cl *ListOperation) RPop(key string) *redis.StringCmd
RPop 从列表的右边删除第一个数据,并返回删除的数据
func (*ListOperation) RPush ¶
func (cl *ListOperation) RPush(key string, value interface{}) *redis.IntCmd
RPush 从列表右边插入数据
func (*ListOperation) RPushX ¶
func (cl *ListOperation) RPushX(key string, value interface{}) *redis.IntCmd
RPushX 跟RPush的区别是,仅当列表存在的时候才插入数据
func (*ListOperation) Range ¶
func (cl *ListOperation) Range(key string, start, stop int64) *redis.StringSliceCmd
Range 返回列表的一个范围内的数据,也可以返回全部数据
func (*ListOperation) RangeAli ¶
func (cl *ListOperation) RangeAli(key string) *redis.StringSliceCmd
RangeAli 返回key全部数据
func (*ListOperation) Rem ¶
func (cl *ListOperation) Rem(key string, count int64, value interface{}) *redis.IntCmd
Rem 删除key中的数据
type MongoClient ¶
type MongoClient struct {
// contains filtered or unexported fields
}
MongoClient 实例
func NewMongoClient ¶
func NewMongoClient(config *MongoClientConfig) (*MongoClient, error)
NewMongoClient 创建实例
func (*MongoClient) Begin ¶
func (c *MongoClient) Begin() *MongoSessionOptions
Begin 开始事务,会同时创建开始会话需要在退出时关闭会话
func (*MongoClient) Database ¶
func (c *MongoClient) Database(name string, opts ...*options.DatabaseOptions) *MongoDatabaseOptions
Database 选择数据库
func (*MongoClient) Model ¶
func (c *MongoClient) Model(value interface{}) *MongoCollectionOptions
Model 传入模型自动获取库名和表名 https://studygolang.com/articles/896 DatabaseName 库名 CollectionName 集合名
type MongoClientCollectionFun ¶ added in v1.0.52
type MongoClientCollectionFun func() (*MongoClient, string, string)
MongoClientCollectionFun *MongoClient 驱动 string 库名 string 集合
type MongoClientConfig ¶ added in v1.0.52
type MongoClientConfig struct { Dns string // 地址 Opts *options.ClientOptions DatabaseName string // 库名 }
MongoClientConfig 实例配置
type MongoClientFun ¶ added in v1.0.52
type MongoClientFun func() (*MongoClient, string)
MongoClientFun *MongoClient 驱动 string 库名
type MongoCollectionOptions ¶ added in v1.0.52
type MongoCollectionOptions struct {
// contains filtered or unexported fields
}
func (*MongoCollectionOptions) Aggregate ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
Aggregate 统计分析
func (*MongoCollectionOptions) CountDocuments ¶ added in v1.0.52
func (cc *MongoCollectionOptions) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
CountDocuments 计数文档
func (*MongoCollectionOptions) CreateManyIndexes ¶ added in v1.0.52
func (cc *MongoCollectionOptions) CreateManyIndexes(ctx context.Context, models []mongo.IndexModel) ([]string, error)
CreateManyIndexes 创建多个索引
func (*MongoCollectionOptions) CreateOneIndexes ¶ added in v1.0.52
func (cc *MongoCollectionOptions) CreateOneIndexes(ctx context.Context, key string, value string) (string, error)
CreateOneIndexes 创建一个索引
func (*MongoCollectionOptions) CreateOneUniqueIndexes ¶ added in v1.0.52
func (cc *MongoCollectionOptions) CreateOneUniqueIndexes(ctx context.Context, key string, value string) (string, error)
CreateOneUniqueIndexes 创建一个唯一索引
func (*MongoCollectionOptions) CreateOneUniqueIndexesOpts ¶ added in v1.0.52
func (cc *MongoCollectionOptions) CreateOneUniqueIndexesOpts(ctx context.Context, key string, value string, opts *options.IndexOptions) (string, error)
CreateOneUniqueIndexesOpts 创建一个索引
func (*MongoCollectionOptions) DeleteMany ¶ added in v1.0.52
func (cc *MongoCollectionOptions) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany 删除多个文档
func (*MongoCollectionOptions) DeleteOne ¶ added in v1.0.52
func (cc *MongoCollectionOptions) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOne 删除一个文档
func (*MongoCollectionOptions) Distinct ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
func (*MongoCollectionOptions) Drop ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Drop(ctx context.Context) error
func (*MongoCollectionOptions) EstimatedDocumentCount ¶ added in v1.0.52
func (cc *MongoCollectionOptions) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)
EstimatedDocumentCount 估计文档计数
func (*MongoCollectionOptions) Find ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
Find 查询多个文档
func (*MongoCollectionOptions) FindOne ¶ added in v1.0.52
func (cc *MongoCollectionOptions) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
FindOne 查询一个文档
func (*MongoCollectionOptions) FindOneAndDelete ¶ added in v1.0.52
func (cc *MongoCollectionOptions) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
func (*MongoCollectionOptions) FindOneAndReplace ¶ added in v1.0.52
func (cc *MongoCollectionOptions) FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult
func (*MongoCollectionOptions) FindOneAndUpdate ¶ added in v1.0.52
func (cc *MongoCollectionOptions) FindOneAndUpdate(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult
func (*MongoCollectionOptions) Indexes ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Indexes(ctx context.Context) mongo.IndexView
func (*MongoCollectionOptions) InsertMany ¶ added in v1.0.52
func (cc *MongoCollectionOptions) InsertMany(ctx context.Context, document []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
InsertMany 插入多个文档
func (*MongoCollectionOptions) InsertOne ¶ added in v1.0.52
func (cc *MongoCollectionOptions) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
InsertOne 插入一个文档
func (*MongoCollectionOptions) ReplaceOne ¶ added in v1.0.52
func (cc *MongoCollectionOptions) ReplaceOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
ReplaceOne 替换一个文档
func (*MongoCollectionOptions) UpdateByID ¶ added in v1.0.52
func (cc *MongoCollectionOptions) UpdateByID(ctx context.Context, id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateByID 按ID更新
func (*MongoCollectionOptions) UpdateMany ¶ added in v1.0.52
func (cc *MongoCollectionOptions) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany 更新多个文档
func (*MongoCollectionOptions) UpdateOne ¶ added in v1.0.52
func (cc *MongoCollectionOptions) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne 更新一个文档
func (*MongoCollectionOptions) Watch ¶ added in v1.0.52
func (cc *MongoCollectionOptions) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
type MongoDatabaseOptions ¶ added in v1.0.52
type MongoDatabaseOptions struct {
// contains filtered or unexported fields
}
func (*MongoDatabaseOptions) Collection ¶ added in v1.0.52
func (cd *MongoDatabaseOptions) Collection(name string, opts ...*options.CollectionOptions) *MongoCollectionOptions
Collection 选择集合
func (*MongoDatabaseOptions) CreateCollection ¶ added in v1.0.52
func (cd *MongoDatabaseOptions) CreateCollection(ctx context.Context, name string, opts ...*options.CreateCollectionOptions) error
CreateCollection 创建集合
func (*MongoDatabaseOptions) CreateTimeSeriesCollection ¶ added in v1.0.52
func (cd *MongoDatabaseOptions) CreateTimeSeriesCollection(ctx context.Context, name string, timeField string) error
CreateTimeSeriesCollection 创建时间序列集合
type MongoSessionCollectionOptions ¶ added in v1.0.52
type MongoSessionCollectionOptions struct {
// contains filtered or unexported fields
}
func (*MongoSessionCollectionOptions) Aggregate ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
Aggregate 统计分析
func (*MongoSessionCollectionOptions) CountDocuments ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) CountDocuments(filter interface{}, opts ...*options.CountOptions) (int64, error)
CountDocuments 计数文档
func (*MongoSessionCollectionOptions) DeleteMany ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany 删除多个文档
func (*MongoSessionCollectionOptions) DeleteOne ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOne 删除一个文档
func (*MongoSessionCollectionOptions) Distinct ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Distinct(fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
func (*MongoSessionCollectionOptions) Drop ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Drop() error
func (*MongoSessionCollectionOptions) EstimatedDocumentCount ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) EstimatedDocumentCount(opts ...*options.EstimatedDocumentCountOptions) (int64, error)
EstimatedDocumentCount 估计文档计数
func (*MongoSessionCollectionOptions) Find ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Find(filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
Find 查询多个文档
func (*MongoSessionCollectionOptions) FindOne ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
FindOne 查询一个文档
func (*MongoSessionCollectionOptions) FindOneAndDelete ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
func (*MongoSessionCollectionOptions) FindOneAndReplace ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) FindOneAndReplace(filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult
func (*MongoSessionCollectionOptions) FindOneAndUpdate ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) FindOneAndUpdate(filter interface{}, replacement interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult
func (*MongoSessionCollectionOptions) Indexes ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Indexes() mongo.IndexView
func (*MongoSessionCollectionOptions) InsertMany ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) InsertMany(document []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
InsertMany 插入多个文档
func (*MongoSessionCollectionOptions) InsertOne ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) InsertOne(document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
InsertOne 插入一个文档
func (*MongoSessionCollectionOptions) ReplaceOne ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) ReplaceOne(filter interface{}, update interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
ReplaceOne 替换一个文档
func (*MongoSessionCollectionOptions) UpdateByID ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) UpdateByID(id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateByID 按ID更新
func (*MongoSessionCollectionOptions) UpdateMany ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) UpdateMany(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany 更新多个文档
func (*MongoSessionCollectionOptions) UpdateOne ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) UpdateOne(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne 更新一个文档
func (*MongoSessionCollectionOptions) Watch ¶ added in v1.0.52
func (csc *MongoSessionCollectionOptions) Watch(pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
type MongoSessionDatabaseOptions ¶ added in v1.0.52
type MongoSessionDatabaseOptions struct {
// contains filtered or unexported fields
}
func (*MongoSessionDatabaseOptions) Collection ¶ added in v1.0.52
func (csd *MongoSessionDatabaseOptions) Collection(name string, opts ...*options.CollectionOptions) *MongoSessionCollectionOptions
Collection 选择集合
type MongoSessionOptions ¶ added in v1.0.52
type MongoSessionOptions struct {
// contains filtered or unexported fields
}
func (*MongoSessionOptions) Commit ¶ added in v1.0.52
func (cs *MongoSessionOptions) Commit()
Commit 提交事务
func (*MongoSessionOptions) Database ¶ added in v1.0.52
func (cs *MongoSessionOptions) Database(name string, opts ...*options.DatabaseOptions) *MongoSessionDatabaseOptions
Database 选择数据库
func (*MongoSessionOptions) GetDb ¶ added in v1.0.52
func (cs *MongoSessionOptions) GetDb() *mongo.Client
GetDb 获取驱动
func (*MongoSessionOptions) GetSession ¶ added in v1.0.52
func (cs *MongoSessionOptions) GetSession() mongo.Session
GetSession 获取会话
func (*MongoSessionOptions) GetSessionContext ¶ added in v1.0.52
func (cs *MongoSessionOptions) GetSessionContext() mongo.SessionContext
GetSessionContext 获取会话上下文
func (*MongoSessionOptions) Model ¶ added in v1.0.52
func (cs *MongoSessionOptions) Model(value interface{}) *MongoSessionCollectionOptions
Model 传入模型自动获取库名和表名 https://studygolang.com/articles/896 DatabaseName 库名 CollectionName 集合名
func (*MongoSessionOptions) Rollback ¶ added in v1.0.52
func (cs *MongoSessionOptions) Rollback()
Rollback 回滚事务
type OperationAttr ¶
type OperationAttr struct { Name string Value interface{} }
func WithNX ¶
func WithNX() *OperationAttr
type OperationAttrs ¶
type OperationAttrs []*OperationAttr
func (OperationAttrs) Find ¶
func (a OperationAttrs) Find(name string) interface{}
type RedisCacheConfig ¶ added in v1.0.51
RedisCacheConfig 配置
type RedisClient ¶
type RedisClient struct { Db *redis.Client // 驱动 // contains filtered or unexported fields }
RedisClient https://redis.uptrace.dev/
func NewRedisClient ¶
func NewRedisClient(config *RedisClientConfig) (*RedisClient, error)
func (*RedisClient) Decr ¶ added in v1.0.51
func (r *RedisClient) Decr(ctx context.Context, key string) *redis.IntCmd
Decr 针对一个key的数值进行递减操作
func (*RedisClient) DecrBy ¶ added in v1.0.51
func (r *RedisClient) DecrBy(ctx context.Context, key string, value int64) *redis.IntCmd
DecrBy 针对一个key的数值进行递减操作,指定每次递减多少
func (*RedisClient) Del ¶ added in v1.0.51
func (r *RedisClient) Del(ctx context.Context, keys ...string) *redis.IntCmd
Del 删除key操作,支持批量删除
func (*RedisClient) Get ¶ added in v1.0.51
func (r *RedisClient) Get(ctx context.Context, key string) *redis.StringCmd
Get 查询key的值
func (*RedisClient) GetSet ¶ added in v1.0.51
func (r *RedisClient) GetSet(ctx context.Context, key string, value interface{}) *redis.StringCmd
GetSet 设置一个key的值,并返回这个key的旧值
func (*RedisClient) Incr ¶ added in v1.0.51
func (r *RedisClient) Incr(ctx context.Context, key string) *redis.IntCmd
Incr 针对一个key的数值进行递增操作
func (*RedisClient) IncrBy ¶ added in v1.0.51
func (r *RedisClient) IncrBy(ctx context.Context, key string, value int64) *redis.IntCmd
IncrBy 针对一个key的数值进行递增操作,指定每次递增多少
func (*RedisClient) Keys ¶ added in v1.0.51
func (r *RedisClient) Keys(ctx context.Context, prefix string) []string
Keys 按前缀获取所有key名
func (*RedisClient) KeysValue ¶ added in v1.0.52
func (r *RedisClient) KeysValue(ctx context.Context, prefix string) *redis.SliceCmd
KeysValue 按前缀获取所有key值
func (*RedisClient) MGet ¶ added in v1.0.51
func (r *RedisClient) MGet(ctx context.Context, keys ...string) *redis.SliceCmd
MGet 批量查询key的值
func (*RedisClient) MSet ¶ added in v1.0.51
func (r *RedisClient) MSet(ctx context.Context, values map[string]interface{}) *redis.StatusCmd
MSet 批量设置key的值 MSet(map[string]interface{}{"key1": "value1", "key2": "value2"})
func (*RedisClient) NewCache ¶ added in v1.0.51
func (r *RedisClient) NewCache(config *RedisCacheConfig) *RedisClientCache
NewCache 实例化
func (*RedisClient) NewCacheDefaultExpiration ¶ added in v1.0.51
func (r *RedisClient) NewCacheDefaultExpiration() *RedisClientCache
NewCacheDefaultExpiration 实例化
func (*RedisClient) NewListOperation ¶
func (r *RedisClient) NewListOperation() *ListOperation
NewListOperation 列表(list)类型数据操作 https://www.tizi365.com/archives/299.html
func (*RedisClient) NewLock ¶ added in v1.0.52
func (r *RedisClient) NewLock() *RedisClientLock
NewLock 实例化锁
func (*RedisClient) NewSimpleCache ¶
func (r *RedisClient) NewSimpleCache(operation *StringOperation, expire time.Duration, serializer string) *SimpleCache
NewSimpleCache 构造函数
func (*RedisClient) NewSimpleInterfaceCache ¶
func (r *RedisClient) NewSimpleInterfaceCache(operation *SimpleOperation, expire time.Duration) *SimpleInterfaceCache
NewSimpleInterfaceCache 构造函数
func (*RedisClient) NewSimpleJsonCache ¶
func (r *RedisClient) NewSimpleJsonCache(operation *StringOperation, expire time.Duration) *SimpleJsonCache
NewSimpleJsonCache 构造函数
func (*RedisClient) NewSimpleOperation ¶
func (r *RedisClient) NewSimpleOperation() *SimpleOperation
func (*RedisClient) NewSimpleStringCache ¶
func (r *RedisClient) NewSimpleStringCache(operation *StringOperation, expire time.Duration) *SimpleStringCache
NewSimpleStringCache 构造函数
func (*RedisClient) NewStringOperation ¶
func (r *RedisClient) NewStringOperation() *StringOperation
func (*RedisClient) PSubscribe ¶ added in v1.0.51
func (r *RedisClient) PSubscribe(ctx context.Context, channels ...string) *redis.PubSub
PSubscribe 订阅channel支持通配符匹配
func (*RedisClient) PubSubChannels ¶ added in v1.0.51
func (r *RedisClient) PubSubChannels(ctx context.Context, pattern string) *redis.StringSliceCmd
PubSubChannels 查询活跃的channel
func (*RedisClient) PubSubNumSub ¶ added in v1.0.51
func (r *RedisClient) PubSubNumSub(ctx context.Context, channels ...string) *redis.MapStringIntCmd
PubSubNumSub 查询指定的channel有多少个订阅者
func (*RedisClient) Publish ¶ added in v1.0.51
func (r *RedisClient) Publish(ctx context.Context, channel string, message interface{}) *redis.IntCmd
Publish 将信息发送到指定的channel
func (*RedisClient) Set ¶ added in v1.0.51
func (r *RedisClient) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
Set 设置一个key的值
type RedisClientCache ¶ added in v1.0.51
type RedisClientCache struct { GetterString GttStringFunc // 不存在的操作 GetterInterface GttInterfaceFunc // 不存在的操作 // contains filtered or unexported fields }
RedisClientCache https://github.com/go-redis/redis
func (*RedisClientCache) GetInterface ¶ added in v1.0.51
func (rc *RedisClientCache) GetInterface(ctx context.Context, key string, result interface{})
GetInterface 缓存操作
func (*RedisClientCache) GetInterfaceKey ¶ added in v1.0.51
func (rc *RedisClientCache) GetInterfaceKey(ctx context.Context, key string, result interface{}) error
GetInterfaceKey 获取key值
func (*RedisClientCache) GetString ¶ added in v1.0.51
func (rc *RedisClientCache) GetString(ctx context.Context, key string) (ret string)
GetString 缓存操作
func (*RedisClientCache) SetInterfaceKey ¶ added in v1.0.51
func (rc *RedisClientCache) SetInterfaceKey(ctx context.Context, key string, value interface{}) (string, error)
SetInterfaceKey 设置key值
type RedisClientConfig ¶ added in v1.0.52
type RedisClientFun ¶ added in v1.0.52
type RedisClientFun func() *RedisClient
RedisClientFun *RedisClient 驱动
type RedisClientLock ¶ added in v1.0.52
type RedisClientLock struct {
// contains filtered or unexported fields
}
RedisClientLock https://github.com/go-redis/redis
func (*RedisClientLock) Lock ¶ added in v1.0.52
func (rl *RedisClientLock) Lock(ctx context.Context, key string, val string, ttl time.Duration) (resp string, err error)
Lock 上锁 key 锁名 val 锁内容 ttl 锁过期时间
func (*RedisClientLock) LockForever ¶ added in v1.0.52
func (rl *RedisClientLock) LockForever(ctx context.Context, key string, val string) (resp string, err error)
LockForever 永远上锁 key 锁名 val 锁内容
type SimpleCache ¶
type SimpleCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过去时间 DBGetter DBGttFunc // 缓存不存在的操作 DB JsonGetter JsonGttFunc // 缓存不存在的操作 JSON Serializer string // 序列化方式 }
SimpleCache 缓存
type SimpleInterfaceCache ¶
type SimpleInterfaceCache struct { Operation *SimpleOperation // 操作类 Expire time.Duration // 过期时间 DBGetter DBGttInterfaceFunc // 缓存不存在的操作 DB }
SimpleInterfaceCache 缓存
type SimpleJsonCache ¶
type SimpleJsonCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过期时间 DBGetter DBGttJsonFunc // 缓存不存在的操作 DB }
SimpleJsonCache 缓存
type SimpleOperation ¶
type SimpleOperation struct {
// contains filtered or unexported fields
}
func (*SimpleOperation) Del ¶
func (o *SimpleOperation) Del(ctx context.Context, keys ...string) *redis.IntCmd
Del 删除key操作,支持批量删除
func (*SimpleOperation) Get ¶
func (o *SimpleOperation) Get(ctx context.Context, key string) *SimpleResult
Get 获取单个
func (*SimpleOperation) Set ¶
func (o *SimpleOperation) Set(ctx context.Context, key string, value interface{}, attrs ...*OperationAttr) *SimpleResult
Set 设置
type SimpleResult ¶
type SimpleResult struct { Result interface{} Err error }
func NewSimpleResult ¶
func NewSimpleResult(result interface{}, err error) *SimpleResult
NewSimpleResult 构造函数
func (*SimpleResult) UnwrapOr ¶
func (r *SimpleResult) UnwrapOr(defaults interface{}) interface{}
UnwrapOr 空值情况下设置返回默认值
func (*SimpleResult) UnwrapOrElse ¶
func (r *SimpleResult) UnwrapOrElse(f func() interface{}) interface{}
UnwrapOrElse 空值情况下设置返回其他
type SimpleStringCache ¶
type SimpleStringCache struct { Operation *StringOperation // 操作类 Expire time.Duration // 过期时间 DBGetter DBGttStringFunc // 缓存不存在的操作 DB }
SimpleStringCache 缓存
type SliceResult ¶
type SliceResult struct { Result []interface{} Err error }
func NewSliceResult ¶
func NewSliceResult(result []interface{}, err error) *SliceResult
NewSliceResult 构造函数
func (*SliceResult) Iter ¶
func (r *SliceResult) Iter() *Iterator
func (*SliceResult) UnwrapOr ¶
func (r *SliceResult) UnwrapOr(defaults []interface{}) []interface{}
UnwrapOr 空值情况下设置返回默认值
type StringOperation ¶
type StringOperation struct {
// contains filtered or unexported fields
}
func (*StringOperation) Del ¶
func (o *StringOperation) Del(ctx context.Context, keys ...string) *redis.IntCmd
Del 删除key操作,支持批量删除
func (*StringOperation) Get ¶
func (o *StringOperation) Get(ctx context.Context, key string) *StringResult
Get 获取单个
func (*StringOperation) MGet ¶
func (o *StringOperation) MGet(ctx context.Context, keys ...string) *SliceResult
MGet 获取多个
func (*StringOperation) Set ¶
func (o *StringOperation) Set(ctx context.Context, key string, value interface{}, attrs ...*OperationAttr) *StringResult
Set 设置
type StringResult ¶
func NewStringResult ¶
func NewStringResult(result string, err error) *StringResult
NewStringResult 构造函数
func (*StringResult) UnwrapOr ¶
func (r *StringResult) UnwrapOr(defaults string) string
UnwrapOr 空值情况下设置返回默认值
func (*StringResult) UnwrapOrElse ¶
func (r *StringResult) UnwrapOrElse(f func() string) string
UnwrapOrElse 空值情况下设置返回其他
type XormClient ¶
XormClient https://xorm.io/
func NewXormMysqlClient ¶
func NewXormMysqlClient(config *XormClientConfigXorm) (*XormClient, error)
func NewXormPostgresClient ¶
func NewXormPostgresClient(config *XormClientConfigXorm) (*XormClient, error)
type XormClientConfigXorm ¶ added in v1.0.52
type XormClientConfigXorm struct {
Dns string // 地址
}
type XormClientSession ¶
XormClientSession https://xorm.io/zh/docs/chapter-10/readme/
Source Files ¶
- gorm.go
- gorm_error.go
- gorm_get.go
- gorm_mysql.go
- gorm_postgresql.go
- gorm_transaction.go
- json.go
- mongo.go
- mongo_collection.go
- mongo_collection_curd.go
- mongo_database.go
- mongo_error.go
- mongo_get.go
- mongo_session.go
- mongo_session_collection.go
- mongo_session_collection_curd.go
- mongo_session_database.go
- mongo_session_get.go
- mongo_time.go
- redis.go
- redis_Iterator.go
- redis_cache.go
- redis_curd.go
- redis_curd_channel.go
- redis_error.go
- redis_get.go
- redis_hash_operation.go
- redis_list_operation.go
- redis_lock.go
- redis_operation_attr.go
- redis_simple_cache.go
- redis_simple_interface_cache.go
- redis_simple_json_cache.go
- redis_simple_operation.go
- redis_simple_result.go
- redis_simple_sring_cache.go
- redis_slice_result.go
- redis_string_operation.go
- redis_string_result.go
- type.go
- xml.go
- xorm.go
- xorm_get.go
- xorm_mysql.go
- xorm_postgres.go
- xorm_transaction.go