elements

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: MIT Imports: 3 Imported by: 0

README

elements GoDoc Go Report Card Commitizen friendly

Overview

Package elements defines new interfaces for mgo objects.

This package creates interfaces that represents the mgo package main objects. These interfaces would be used between themselves, allowing easy mocking on the objects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeInfo

type ChangeInfo struct {
	*mgo.ChangeInfo
}

ChangeInfo it's an embedded type of mgo.ChangeInfo, made to reduce importing to this package only, since it's necessary on other functions.

func NewChangeInfo

func NewChangeInfo(u, r, m int, id interface{}) (c *ChangeInfo)

NewChangeInfo creates a new embedded ChangeInfo, with all attributes for class.

func NewRemoveInfo

func NewRemoveInfo(r int) (c *ChangeInfo)

NewRemoveInfo creates a new embedded ChangeInfo, with all attributes returned on calls to Remove.

type Collectioner

type Collectioner interface {
	Bulk() *mgo.Bulk
	Count() (int, error)
	Create(*mgo.CollectionInfo) error
	DropCollection() error
	DropIndex(...string) error
	DropIndexName(string) error
	EnsureIndex(mgo.Index) error
	EnsureIndexKey(...string) error
	Find(interface{}) Querier
	FindID(interface{}) Querier
	Indexes() ([]mgo.Index, error)
	Insert(docs ...interface{}) error
	NewIter(*mgo.Session, []bson.Raw, int64, error) *mgo.Iter
	Pipe(interface{}) *mgo.Pipe
	Remove(interface{}) error
	RemoveAll(interface{}) (*ChangeInfo, error)
	RemoveID(interface{}) error
	Repair() *mgo.Iter
	Update(interface{}, interface{}) error
	UpdateAll(interface{}, interface{}) (*ChangeInfo, error)
	UpdateID(interface{}, interface{}) error
	Upsert(interface{}, interface{}) (*ChangeInfo, error)
	UpsertID(interface{}, interface{}) (*ChangeInfo, error)
	With(*mgo.Session) Collectioner
}

Collectioner is the interface that tries to enumerate all methods that mgo.Collection have, with the difference of using the interfaces on this package, instead of mgo.Collection, mgo.Database and mgo.Query.

type Databaser

type Databaser interface {
	AddUser(string, string, bool) error
	C(string) Collectioner
	CollectionNames() ([]string, error)
	DropDatabase() error
	FindRef(*mgo.DBRef) Querier
	GridFS(string) *mgo.GridFS
	Login(string, string) error
	Logout()
	RemoveUser(string) error
	Run(interface{}, interface{}) error
	UpsertUser(*mgo.User) error
	With(*mgo.Session) Databaser
}

Databaser is the interface that tries to enumerate all methods that mgo.Database have, with the difference of using the interfaces on this package, instead of mgo.Collection, mgo.Database and mgo.Query.

type DialInfo added in v0.8.0

type DialInfo struct {
	*mgo.DialInfo
}

DialInfo it's an embedded type of mgo.DialInfo, made to reduce importing to this package only, since it's necessary on other functions.

func NewDatabaseInfo added in v0.8.0

func NewDatabaseInfo(db string) (d *DialInfo)

NewDatabaseInfo creates a new simplified DialInfo, with only Database attribute set.

func NewDialInfo added in v0.8.0

func NewDialInfo(info *mgo.DialInfo) (d *DialInfo)

NewDialInfo creates a new embedded DialInfo, with all attributes for class.

type Querier

type Querier interface {
	All(interface{}) error
	Apply(mgo.Change, interface{}) (*mgo.ChangeInfo, error)
	Batch(int) Querier
	Comment(string) Querier
	Count() (int, error)
	Distinct(string, interface{}) error
	Explain(interface{}) error
	For(interface{}, func() error) error
	Hint(...string) Querier
	Iter() *mgo.Iter
	Limit(int) Querier
	LogReplay() Querier
	MapReduce(*mgo.MapReduce, interface{}) (*mgo.MapReduceInfo, error)
	One(interface{}) error
	Prefetch(float64) Querier
	Select(interface{}) Querier
	SetMaxScan(int) Querier
	SetMaxTime(time.Duration) Querier
	Skip(int) Querier
	Snapshot() Querier
	Sort(...string) Querier
	Tail(time.Duration) *mgo.Iter
}

Querier is the interface that tries to enumerate all methods that mgo.Query have, with the difference of using the interfaces on this package, instead of mgo.Collection, mgo.Database and mgo.Query.

type Sessioner added in v0.8.0

type Sessioner interface {
	SetSafe(*mgo.Safe)
	Clone() Sessioner
	Close()
	DB(string) Databaser
}

Sessioner is the interface that tries to enumerate some methods that mgo.Session have, with the difference of using the interfaces on this package, instead of mgo.Collection, mgo.Database and mgo.Query.

Jump to

Keyboard shortcuts

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