session

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close : closes the main session.

func Copy

func Copy() (*mgo.Session, *mgo.Database)

Copy : copies the main session.

func Get

func Get(c *gin.Context) *mgo.Database

Get : returns the mongodb session saved into a request.

func Initialize

func Initialize(address, database, username, password string, timeout time.Duration)

Initialize : initializes the main mongodb session.

func Inject

func Inject() gin.HandlerFunc

Inject : saves a mongodb session to the context.

Types

type Session

type Session struct {
	Session      *mgo.Session
	DatabaseName string
}

Session : session of a mongo database.

var Main *Session

Main : main mongo session of the application.

func NewSession

func NewSession() (session *Session)

NewSession : returns a new Session struct

func (*Session) Close

func (session *Session) Close()

Close : closes the session.

func (*Session) Copy

func (session *Session) Copy() (*mgo.Session, *mgo.Database)

Copy : copies the session.

func (*Session) Initialize

func (session *Session) Initialize(address, database, username, password string, timeout time.Duration)

Initialize : initializes the global mongodb session.

func (*Session) Inject

func (session *Session) Inject() gin.HandlerFunc

Inject : saves a mongodb session to the context.

Jump to

Keyboard shortcuts

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