Documentation ¶
Index ¶
- Variables
- type MongoDB
- type RCO
- type Repository
- func (r *Repository) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (r *Repository) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (r *Repository) Find(ctx context.Context, entityList interface{}, filter interface{}, ...) error
- func (r *Repository) FindOne(ctx context.Context, entity interface{}, filter interface{}, ...) error
- func (r *Repository) FindOneAndUpdate(ctx context.Context, entity interface{}, filter interface{}, ...) error
- func (r *Repository) InsertOne(ctx context.Context, doc interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (r *Repository) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (r *Repository) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type RepositoryCache
- func (r *RepositoryCache) DelCache(ctx context.Context, key string)
- func (r *RepositoryCache) DelCacheByFilter(ctx context.Context, filter interface{})
- func (r *RepositoryCache) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (r *RepositoryCache) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (r *RepositoryCache) Find(ctx context.Context, entityList interface{}, filter interface{}, ...) error
- func (r *RepositoryCache) FindOne(ctx context.Context, entity interface{}, filter interface{}, ...) error
- func (r *RepositoryCache) FindOneAndUpdate(ctx context.Context, entity interface{}, filter interface{}, ...) error
- func (r *RepositoryCache) GenCacheK(filter interface{}) (string, error)
- func (r *RepositoryCache) InsertOne(ctx context.Context, doc interface{}, filter interface{}, ...) (*mongo.InsertOneResult, error)
- func (r *RepositoryCache) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (r *RepositoryCache) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type RepositoryCacheOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCacheMiss = errors.New("cache miss")
Functions ¶
This section is empty.
Types ¶
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func GetMongoDB
deprecated
func GetMongoDB(opt *options.ClientOptions, database string) *MongoDB
Deprecated: GetMongoDB 方法已废弃,请使用 NewMongoDB 直接创建实例。
func NewMongoDB ¶
func NewMongoDB(opt *options.ClientOptions, database string) *MongoDB
func (*MongoDB) Disconnect ¶
func (m *MongoDB) Disconnect()
func (*MongoDB) GetCollection ¶
func (m *MongoDB) GetCollection(collectionName string) *mongo.Collection
func (*MongoDB) GetDatabase ¶
type RCO ¶
type RCO = RepositoryCacheOption
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func GetRepository ¶
func GetRepository(db *MongoDB, collection string) *Repository
func (*Repository) DeleteMany ¶
func (r *Repository) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Repository) DeleteOne ¶
func (r *Repository) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Repository) Find ¶
func (r *Repository) Find(ctx context.Context, entityList interface{}, filter interface{}, opts ...*options.FindOptions) error
func (*Repository) FindOne ¶
func (r *Repository) FindOne(ctx context.Context, entity interface{}, filter interface{}, opts ...*options.FindOneOptions) error
func (*Repository) FindOneAndUpdate ¶
func (r *Repository) FindOneAndUpdate(ctx context.Context, entity interface{}, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
func (*Repository) InsertOne ¶
func (r *Repository) InsertOne(ctx context.Context, doc interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*Repository) UpdateMany ¶
func (r *Repository) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Repository) UpdateOne ¶
func (r *Repository) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type RepositoryCache ¶
type RepositoryCache struct { *Repository // contains filtered or unexported fields }
func GetRepositoryCache ¶
func GetRepositoryCache(repo *Repository, cache redis.UniversalClient, opt *RepositoryCacheOption) *RepositoryCache
func (*RepositoryCache) DelCache ¶
func (r *RepositoryCache) DelCache(ctx context.Context, key string)
func (*RepositoryCache) DelCacheByFilter ¶
func (r *RepositoryCache) DelCacheByFilter(ctx context.Context, filter interface{})
func (*RepositoryCache) DeleteMany ¶
func (r *RepositoryCache) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*RepositoryCache) DeleteOne ¶
func (r *RepositoryCache) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*RepositoryCache) Find ¶
func (r *RepositoryCache) Find(ctx context.Context, entityList interface{}, filter interface{}, opts ...*options.FindOptions) error
func (*RepositoryCache) FindOne ¶
func (r *RepositoryCache) FindOne(ctx context.Context, entity interface{}, filter interface{}, opts ...*RepositoryCacheOption) error
func (*RepositoryCache) FindOneAndUpdate ¶
func (r *RepositoryCache) FindOneAndUpdate(ctx context.Context, entity interface{}, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
func (*RepositoryCache) GenCacheK ¶
func (r *RepositoryCache) GenCacheK(filter interface{}) (string, error)
func (*RepositoryCache) InsertOne ¶
func (r *RepositoryCache) InsertOne(ctx context.Context, doc interface{}, filter interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (*RepositoryCache) UpdateMany ¶
func (r *RepositoryCache) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*RepositoryCache) UpdateOne ¶
func (r *RepositoryCache) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type RepositoryCacheOption ¶
Click to show internal directories.
Click to hide internal directories.