mongodb

package
Version: v0.0.0-...-a85dc47 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MongoDbKey domain.ContextKey = "slumber-mddlwr-mongodb-key"

Variables

This section is empty.

Functions

func SetMongoDbCtx

func SetMongoDbCtx(ctx domain.IContext, r *http.Request, db *MongoDB)

Types

type MongoDB

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

MongoDatabase implements IDatabase

func GetMongoDbCtx

func GetMongoDbCtx(ctx domain.IContext, r *http.Request) *MongoDB

func New

func New(options *Options) *MongoDB

func (*MongoDB) Count

func (db *MongoDB) Count(name string, query domain.Query) (int, error)

func (*MongoDB) DropCollection

func (db *MongoDB) DropCollection(name string) error

func (*MongoDB) DropDatabase

func (db *MongoDB) DropDatabase() error

func (*MongoDB) EnsureIndex

func (db *MongoDB) EnsureIndex(name string, index mgo.Index) error

func (*MongoDB) Exists

func (db *MongoDB) Exists(name string, query domain.Query) bool

func (*MongoDB) FindAll

func (db *MongoDB) FindAll(name string, query domain.Query, result interface{}, limit int, sort string) error

func (*MongoDB) FindOne

func (db *MongoDB) FindOne(name string, query domain.Query, result interface{}) error

func (*MongoDB) Insert

func (db *MongoDB) Insert(name string, obj interface{}) error

func (*MongoDB) NewSession

func (db *MongoDB) NewSession() *MongoDBSession

func (*MongoDB) RemoveAll

func (db *MongoDB) RemoveAll(name string, query domain.Query) error

func (*MongoDB) RemoveOne

func (db *MongoDB) RemoveOne(name string, query domain.Query) error

func (*MongoDB) Update

func (db *MongoDB) Update(name string, query domain.Query, change domain.Change, result interface{}) error

func (*MongoDB) UpdateAll

func (db *MongoDB) UpdateAll(name string, query domain.Query, change domain.Query) (int, error)

type MongoDBSession

type MongoDBSession struct {
	*mgo.Session
	*Options
}

MongoDatabaseSession struct implements IContextMiddleware

func (*MongoDBSession) Handler

func (session *MongoDBSession) Handler(w http.ResponseWriter, req *http.Request, next http.HandlerFunc, ctx domain.IContext)

Handler Returns a middleware HandlerFunc that creates and saves a database session into request context

type Options

type Options struct {
	ServerName   string
	DatabaseName string
	DialTimeout  time.Duration
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL