db

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

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

Go to latest
Published: Aug 18, 2020 License: MIT Imports: 6 Imported by: 0

README

go-db

A simple go module for instantiating a connection to mongodb and reusing it across the go process.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close resets the state, clearing the persisted client and db objects. Initialize() must be called again.

func GetDatabase

func GetDatabase() (*mongo.Database, error)

GetDatabase returns the instantiated database or errors if Initialize() has not been called

func Initialize

func Initialize(o *ConnectOptions) (*mongo.Database, error)

Initialize a new connection to the database

Types

type ConnectOptions

type ConnectOptions struct {
	ConnectTimeout time.Duration
	DatabaseURL    string
	Database       string
}

ConnectOptions are connection options for the database connection

Jump to

Keyboard shortcuts

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