copy

package
v0.0.0-...-4bb1132 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ops *CollectionInfo, query interface{}) error

Delete remove documents from a collection.

func GetByID

func GetByID(ops *CollectionInfo, id interface{}, i interface{}) error

GetByID get a single record by ID

func GetLimitedRecords

func GetLimitedRecords(ops *CollectionInfo, q interface{}, n int, doc interface{}, fields ...string) error

GetLimitedRecords obtain records based on specified conditions. The results of the specified number of returns are sorted by the specified fields.

func GetMany

func GetMany(ops *CollectionInfo, q interface{}, doc interface{}, fields ...string) error

GetMany get multiple records based on a condition, to order returned documents according to the provided field names.

func GetUniqueOne

func GetUniqueOne(ops *CollectionInfo, q interface{}, doc interface{}) error

GetUniqueOne get a single record by query

func Insert

func Insert(ops *CollectionInfo, doc interface{}) error

Insert add new documents to a collection.

func IsValidObjectHex

func IsValidObjectHex(id string) bool

IsValidObjectHex check whether the id can be converted to be a qualified ObjectId

func IsValidObjectID

func IsValidObjectID(id bson.ObjectId) bool

IsValidObjectID check whether the id is a qualified ObjectId

func IterAll

func IterAll(ops *CollectionInfo, pipeline interface{}, i interface{}) error

IterAll prepares a pipeline to aggregate and executes the pipeline, works like Iter.All.

func PrepareCollection

func PrepareCollection(ops *CollectionInfo) (*mgo.Collection, chan struct{})

func Update

func Update(ops *CollectionInfo, query interface{}, i interface{}) error

Update modify existing documents in a collection.

func UpdateByQueryField

func UpdateByQueryField(ops *CollectionInfo, q interface{}, field string, value interface{}) (*mgo.ChangeInfo, error)

UpdateByQueryField modify all eligible documents.

func Upsert

func Upsert(ops *CollectionInfo, query interface{}, i interface{}) (*mgo.ChangeInfo, error)

Upsert creates a new document and inserts it if no documents match the specified filter. If there are matching documents, then the operation modifies or replaces the matching document or documents.

Types

type CollectionInfo

type CollectionInfo struct {
	Session    *mgo.Session
	Database   string
	Collection string
	Index      *mgo.Index
}

Jump to

Keyboard shortcuts

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