Documentation ¶
Index ¶
- Variables
- func AllItems(dbs *mongo.Database, colName string) ([]bson.M, error)
- func CheckConnection(client *mongo.Client) bool
- func CreateEntries(dbs *mongo.Database, collection string, docs []interface{}) ([]interface{}, error)
- func CreateEntry(dbs *mongo.Database, collection string, doc bson.D) (interface{}, error)
- func RemoveMany(collection *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)
- func RemoveOne(collection *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)
- func SingleItem(collection *mongo.Collection, filter bson.D) (bson.D, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Database *mongo.Database Client *mongo.Client Collection *mongo.Collection )
declare variables
Functions ¶
func CheckConnection ¶
CheckConnection checks server connectivity using the Ping method Calling Connect does not block for server discovery.
func CreateEntries ¶ added in v1.5.0
func CreateEntries(dbs *mongo.Database, collection string, docs []interface{}) ([]interface{}, error)
CreateEntries adds records(docs) to the database(dbs) into Collection(collection) returns the id's created and possible error
func CreateEntry ¶
CreateEntry adds a record(doc) to the database(dbs) into Collection(collection)
func RemoveMany ¶ added in v1.5.0
func RemoveMany(collection *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)
RemoveMany deletes multiple record from a collection
func RemoveOne ¶ added in v1.5.0
func RemoveOne(collection *mongo.Collection, filter interface{}) (*mongo.DeleteResult, error)
RemoveOne deletes a record from a collection
func SingleItem ¶
SingleItem returns a single item from the database For methods that return a single item, a SingleResult, which works like a *sql.Row: filter := bson.D{{"name", "pi"}}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.