mongodb

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ElementKey = micro.ElementKey("MongodbComponent")

ElementKey is ElementKey for mongodb

Functions

func CreateDB

func CreateDB(config Config) (*mongo.Client, error)

CreateDB create db

Types

type Config

type Config struct {
	Address  string `toml:"host"`     // Server address
	DB       string `toml:"db"`       // database name
	User     string `toml:"user"`     // user name
	Password string `toml:"password"` // password
	Options  string `toml:"options"`  // config
}

Config database configuration

func GetMongoConfig

func GetMongoConfig() *Config

GetMongoConfig get database configuration

type MongoComponent

type MongoComponent struct {
	micro.EmptyComponent
	// contains filtered or unexported fields
}

MongoComponent is Component for mongodb

func (*MongoComponent) Init

func (c *MongoComponent) Init(server *micro.Server) error

Init the component

func (*MongoComponent) Name

func (c *MongoComponent) Name() string

Name of the component

func (*MongoComponent) PostStop

func (c *MongoComponent) PostStop(ctx context.Context) error

PostStop called after Stop()

func (*MongoComponent) PreInit

func (c *MongoComponent) PreInit(ctx context.Context) error

PreInit called before Init()

Jump to

Keyboard shortcuts

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