Documentation ¶
Index ¶
- func Delete(session *mgo.Session, collection *mgo.Collection, query interface{}) error
- func GetByID(session *mgo.Session, collection *mgo.Collection, id interface{}, ...)
- func GetMany(session *mgo.Session, collection *mgo.Collection, q interface{}, ...) error
- func GetUniqueOne(session *mgo.Session, collection *mgo.Collection, q interface{}, ...) error
- func Insert(session *mgo.Session, collection *mgo.Collection, doc interface{}) error
- func IsValidObjectHex(id string) bool
- func IsValidObjectID(id bson.ObjectId) bool
- func Update(session *mgo.Session, collection *mgo.Collection, query interface{}, ...) error
- func UpdateByQueryField(session *mgo.Session, collection *mgo.Collection, q interface{}, field string, ...) (*mgo.ChangeInfo, error)
- func Upsert(session *mgo.Session, collection *mgo.Collection, query interface{}, ...) (*mgo.ChangeInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(session *mgo.Session, collection *mgo.Collection, query interface{}) error
Delete remove documents from a collection.
func GetByID ¶
func GetByID(session *mgo.Session, collection *mgo.Collection, id interface{}, i interface{})
GetByID get a single record by ID
func GetMany ¶
func GetMany(session *mgo.Session, collection *mgo.Collection, q interface{}, doc interface{}) error
GetMany get multiple records based on a condition
func GetUniqueOne ¶
func GetUniqueOne(session *mgo.Session, collection *mgo.Collection, q interface{}, doc interface{}) error
GetUniqueOne get a single record by query
func Insert ¶
func Insert(session *mgo.Session, collection *mgo.Collection, 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 Update ¶
func Update(session *mgo.Session, collection *mgo.Collection, query interface{}, i interface{}) error
Update modify existing documents in a collection.
func UpdateByQueryField ¶
func UpdateByQueryField(session *mgo.Session, collection *mgo.Collection, q interface{}, field string, value interface{}) (*mgo.ChangeInfo, error)
UpdateByQueryField modify all eligible documents.
func Upsert ¶
func Upsert(session *mgo.Session, collection *mgo.Collection, 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 ¶
This section is empty.