mongo

package
v0.0.0-...-4827418 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	User     string = os.Getenv("MONGODB_USERNAME")
	Password string = os.Getenv("MONGODB_PASSWORD")
	Host     string = os.Getenv("MONGODB_HOST")
	Database string = os.Getenv("MONGODB_DATABASE")
	Port     int    = 27017
)

Connection details from env vars or a .env file

Functions

func PanicRecoverHandler

func PanicRecoverHandler(err error)

Just a basic panic recover that can be used in a defer somewhere

Types

type MongoCollection

type MongoCollection interface {
	// Events
	AssureeID() error
	BeforeSave() error
}

type MongoConnector

type MongoConnector struct {
	// contains filtered or unexported fields
}

Basic structure to hold the connection

func (*MongoConnector) Connect

func (d *MongoConnector) Connect() error

Connect to mongo and set up the structure with an active connection

func (*MongoConnector) Disconnect

func (d *MongoConnector) Disconnect() error

Disconnect from mongo (should you ever want to)

func (*MongoConnector) GetCollection

func (d *MongoConnector) GetCollection(name string) *mongo.Collection

return the collection from the active connection

Jump to

Keyboard shortcuts

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