storage

package
v0.0.0-...-538f495 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2014 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	*mgo.Collection
}

Collection represents a database collection. It embeds mgo.Collection for operations, and holds a session to MongoDB. The user may close the session using the method close.

func (*Collection) Close

func (c *Collection) Close()

Close closes the session with the database.

type Storage

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

Storage holds the connection with the database.

func Open

func Open(addr, dbname string) (storage *Storage, err error)

Open dials to the MongoDB database, and return the connection (represented by the type Storage).

addr is a MongoDB connection URI, and dbname is the name of the database.

This function returns a pointer to a Storage, or a non-nil error in case of any failure.

func (*Storage) Close

func (s *Storage) Close()

Close closes the storage, releasing the connection.

func (*Storage) Collection

func (s *Storage) Collection(name string) *Collection

Collection returns a collection by its name.

If the collection does not exist, MongoDB will create it.

func (*Storage) DB

func (s *Storage) DB() *mgo.Database

Jump to

Keyboard shortcuts

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