database

package
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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) GetClient

func (m *MongoDB) GetClient() *mongo.Client

func (*MongoDB) GetCollection

func (m *MongoDB) GetCollection(collectionName string) *mongo.Collection

func (*MongoDB) GetDatabase

func (m *MongoDB) GetDatabase() *mongo.Database

func (*MongoDB) Ping

func (m *MongoDB) Ping(ctx context.Context)

type RCO

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, entity 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) 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, entity 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

type RepositoryCacheOption struct {
	Prefix string
	TTL    int
	Debug  bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL