db

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxMongoKey = util.CtxKey("ctxMongoKey")
	HeaderDBKey = "raccMongoDB"
)
View Source
const (
	CoreDB = "core"
	UserDB = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoConf

type MongoConf struct {
	Uri       string `yaml:"uri"`
	User      string `yaml:"user"`
	Pass      string `yaml:"pass"`
	DefaultDB string `yaml:"defaul"`
	// contains filtered or unexported fields
}

func (*MongoConf) GetUri

func (mc *MongoConf) GetUri() string

func (*MongoConf) NewMongoDBClient

func (mc *MongoConf) NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)

func (*MongoConf) SetAuth

func (mc *MongoConf) SetAuth(user, pwd string)

type MongoDBClient

type MongoDBClient interface {
	GetCoreDB() *mongo.Database
	GetUserDB() *mongo.Database
	WithSession(f func(sc mongo.SessionContext) error) error
	AbortTransaction(sc mongo.SessionContext) error
	CommitTransaction(sc mongo.SessionContext) error
	Close()
	Ping() error
}

func GetMgoDBClientByCtx

func GetMgoDBClientByCtx(ctx context.Context) MongoDBClient

func GetMgoDBClientByGin added in v0.0.6

func GetMgoDBClientByGin(c *gin.Context) MongoDBClient

func GetMgoDBClientByReq

func GetMgoDBClientByReq(req *http.Request) MongoDBClient

type MongoDI

type MongoDI interface {
	NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)
	SetAuth(user, pwd string)
	GetUri() string
}

Jump to

Keyboard shortcuts

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