Documentation ¶
Index ¶
- func Delete(ops *CollectionInfo, query interface{}) error
- func GetByID(ops *CollectionInfo, id interface{}, i interface{}) error
- func GetLimitedRecords(ops *CollectionInfo, q interface{}, n int, doc interface{}, fields ...string) error
- func GetMany(ops *CollectionInfo, q interface{}, doc interface{}, fields ...string) error
- func GetUniqueOne(ops *CollectionInfo, q interface{}, doc interface{}) error
- func Insert(ops *CollectionInfo, doc interface{}) error
- func IsValidObjectHex(id string) bool
- func IsValidObjectID(id bson.ObjectId) bool
- func IterAll(ops *CollectionInfo, pipeline interface{}, i interface{}) error
- func PrepareCollection(ops *CollectionInfo) (*mgo.Collection, chan struct{})
- func Update(ops *CollectionInfo, query interface{}, i interface{}) error
- func UpdateByQueryField(ops *CollectionInfo, q interface{}, field string, value interface{}) (*mgo.ChangeInfo, error)
- func Upsert(ops *CollectionInfo, query interface{}, i interface{}) (*mgo.ChangeInfo, error)
- type CollectionInfo
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 ¶
IsValidObjectHex check whether the id can be converted to be a qualified ObjectId
func IsValidObjectID ¶
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.