mongodb

package module
v0.0.0-...-fbaf9a3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MongoDBURI                      = "mongodb-uri"
	MongoDBAppName                  = "mongodb-app-name"
	MongoDBUsername                 = "mongodb-username"
	MongoDBPassword                 = "mongodb-password"
	MongoDBReplicaSet               = "mongodb-replica-set"
	MongoDBServerSelectionTimeoutMs = "mongodb-server-selection-timeout-ms"
	MongoDBConnectTimeoutMs         = "mongodb-connect-timeout-ms"
	MongoDBSocketTimeoutMs          = "mongodb-socket-timeout-ms"
)

Variables

View Source
var DefaultConfig = &Config{
	URI:                      "mongodb://localhost:27017",
	AppName:                  "",
	Username:                 "",
	Password:                 "",
	ReplicaSet:               "",
	ServerSelectionTimeoutMs: 10 * time.Second,
	ConnectTimeoutMs:         10 * time.Second,
	SocketTimeoutMs:          30 * time.Second,
}

Functions

func CreateIndexes

func CreateIndexes(ctx context.Context, db *mongo.Database, indexes map[string][]mongo.IndexModel) error

func New

func New() (*mongo.Client, error)

Types

type Config

type Config struct {
	URI                      string
	AppName                  string
	Username                 string
	Password                 string
	ReplicaSet               string
	ServerSelectionTimeoutMs time.Duration
	ConnectTimeoutMs         time.Duration
	SocketTimeoutMs          time.Duration // query timeout
}

func (*Config) BindFlags

func (c *Config) BindFlags(fs *pflag.FlagSet)

Jump to

Keyboard shortcuts

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