Documentation ¶
Index ¶
- func SetGlobalPool(ctx context.Context, pool *MongoDBPool)
- type MongoConfig
- type MongoDBPool
- func (pool *MongoDBPool) CloseAll(ctx context.Context) error
- func (pool *MongoDBPool) CloseConnection(ctx context.Context, name string) error
- func (pool *MongoDBPool) GetConfig(ctx context.Context) MongoDBPoolConfig
- func (pool *MongoDBPool) GetConnection(ctx context.Context, name string) (*mongo.Client, error)
- func (pool *MongoDBPool) SetConfig(ctx context.Context, cfg *MongoConfig) error
- func (pool *MongoDBPool) String() string
- type MongoDBPoolConfig
- type MongoDBRepository
- func (self *MongoDBRepository[T]) AttachConnection(ctx context.Context, client *mongo.Client, dbName string) *MongoDBRepository[T]
- func (self *MongoDBRepository[T]) Create(ctx context.Context, t T) (*string, error)
- func (self *MongoDBRepository[T]) Delete(ctx context.Context, id string) error
- func (self *MongoDBRepository[T]) DeleteList(ctx context.Context, ids []string) error
- func (self *MongoDBRepository[T]) GetByID(ctx context.Context, id string) (T, error)
- func (self *MongoDBRepository[T]) GetByIDList(ctx context.Context, ids []string) ([]T, error)
- func (self *MongoDBRepository[T]) GetCollection(ctx context.Context) *mongo.Collection
- func (self *MongoDBRepository[T]) GetRawClient(ctx context.Context) *mongo.Client
- func (self *MongoDBRepository[T]) Save(ctx context.Context, t T) error
- func (self *MongoDBRepository[T]) Update(ctx context.Context, t T) error
- type MongoModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetGlobalPool ¶
func SetGlobalPool(ctx context.Context, pool *MongoDBPool)
Types ¶
type MongoConfig ¶
type MongoDBPool ¶
type MongoDBPool struct {
// contains filtered or unexported fields
}
func GetGlobalPool ¶
func GetGlobalPool(ctx context.Context) *MongoDBPool
func NewGlobalPool ¶
func NewGlobalPool(ctx context.Context, config MongoDBPoolConfig) (*MongoDBPool, error)
func NewMongoDBPool ¶
func NewMongoDBPool(ctx context.Context, config MongoDBPoolConfig) (*MongoDBPool, error)
func (*MongoDBPool) CloseConnection ¶
func (pool *MongoDBPool) CloseConnection(ctx context.Context, name string) error
func (*MongoDBPool) GetConfig ¶
func (pool *MongoDBPool) GetConfig(ctx context.Context) MongoDBPoolConfig
func (*MongoDBPool) GetConnection ¶
func (*MongoDBPool) SetConfig ¶
func (pool *MongoDBPool) SetConfig(ctx context.Context, cfg *MongoConfig) error
func (*MongoDBPool) String ¶
func (pool *MongoDBPool) String() string
type MongoDBPoolConfig ¶
type MongoDBPoolConfig struct {
Config []*MongoConfig `json:"Config" yaml:"Config"`
}
type MongoDBRepository ¶
type MongoDBRepository[T MongoModel] struct { model.Repository[T] // contains filtered or unexported fields }
func NewMongoDBRepository ¶
func NewMongoDBRepository[T MongoModel]() *MongoDBRepository[T]
func (*MongoDBRepository[T]) AttachConnection ¶
func (self *MongoDBRepository[T]) AttachConnection(ctx context.Context, client *mongo.Client, dbName string) *MongoDBRepository[T]
func (*MongoDBRepository[T]) Create ¶
func (self *MongoDBRepository[T]) Create(ctx context.Context, t T) (*string, error)
func (*MongoDBRepository[T]) Delete ¶
func (self *MongoDBRepository[T]) Delete(ctx context.Context, id string) error
func (*MongoDBRepository[T]) DeleteList ¶
func (self *MongoDBRepository[T]) DeleteList(ctx context.Context, ids []string) error
func (*MongoDBRepository[T]) GetByID ¶
func (self *MongoDBRepository[T]) GetByID(ctx context.Context, id string) (T, error)
func (*MongoDBRepository[T]) GetByIDList ¶
func (self *MongoDBRepository[T]) GetByIDList(ctx context.Context, ids []string) ([]T, error)
func (*MongoDBRepository[T]) GetCollection ¶
func (self *MongoDBRepository[T]) GetCollection(ctx context.Context) *mongo.Collection
func (*MongoDBRepository[T]) GetRawClient ¶
func (self *MongoDBRepository[T]) GetRawClient(ctx context.Context) *mongo.Client
type MongoModel ¶
Click to show internal directories.
Click to hide internal directories.