storage

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 6 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.

func (*Collection) Create

func (c *Collection) Create(info *mgo.CollectionInfo) error

func (*Collection) DropCollection

func (c *Collection) DropCollection() error

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) Database

func (s *Storage) Database(name string) *mgo.Database

func (*Storage) DropDatabase

func (s *Storage) DropDatabase(name string) error

DropDatabase drop database of any given name

Jump to

Keyboard shortcuts

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