mongolib

package
v0.0.0-...-29e355a Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalPool

func SetGlobalPool(ctx context.Context, pool *MongoDBPool)

Types

type MongoConfig

type MongoConfig struct {
	Name     string   `json:"Name" yaml:"Name"`
	Alias    []string `json:"Alias" yaml:"Alias"`
	MongoURI string   `json:"MongoURI" yaml:"MongoURI"`
}

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

func (pool *MongoDBPool) CloseAll(ctx context.Context) 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 (pool *MongoDBPool) GetConnection(ctx context.Context, name string) (*mongo.Client, error)

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

func (*MongoDBRepository[T]) Save

func (self *MongoDBRepository[T]) Save(ctx context.Context, t T) error

func (*MongoDBRepository[T]) Update

func (self *MongoDBRepository[T]) Update(ctx context.Context, t T) error

type MongoModel

type MongoModel interface {
	GetID() string
	TableName() string
}

Jump to

Keyboard shortcuts

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