Documentation ¶
Index ¶
- Constants
- func CreateIndex(client *mongo.Client, dbName string, collectionName string, field string, ...) error
- func DeleteManyByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M) (*mongo.DeleteResult, error)
- func DeleteOneByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M) (*mongo.DeleteResult, error)
- func DeleteOneByID(client *mongo.Client, dbName string, collectionName string, ...) (*mongo.DeleteResult, error)
- func FindAll(client *mongo.Client, dbName string, collectionName string, model interface{}, ...) (interface{}, error)
- func FindOne(client *mongo.Client, dbName string, collectionName string, model interface{}, ...) (interface{}, error)
- func InsertMany(client *mongo.Client, dbName string, collectionName string, ...) (*mongo.InsertManyResult, error)
- func InsertOne(client *mongo.Client, dbName string, collectionName string, model interface{}) (*mongo.InsertOneResult, error)
- func ReturnAuthenticatedClient(url string, authDB string, user string, password string, appName string, ...) (*mongo.Client, error)
- func ReturnAuthenticatedClientMongoAtlas(url string, user string, password string, db string, appName string, ...) (*mongo.Client, error)
- func ReturnClient(url string, appName string, createMonitor bool) (*mongo.Client, error)
- func Total(client *mongo.Client, dbName string, collectionName string, filter bson.M) (int64, error)
- func UpdateByID(client *mongo.Client, dbName string, collectionName string, ...) (*mongo.UpdateResult, error)
- func UpdateManyByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M, ...) (*mongo.UpdateResult, error)
- func UpdateOneByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M, ...) (*mongo.UpdateResult, error)
Constants ¶
View Source
const ConnectTimeout = 10 * time.Second
View Source
const MaxConnIdleTime = 15 * time.Second
View Source
const ServerSelectionTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
func CreateIndex ¶ added in v1.7.0
func CreateIndex(client *mongo.Client, dbName string, collectionName string, field string, unique bool) error
Create an index with the provide name and condition
func DeleteManyByFilter ¶ added in v1.5.0
func DeleteManyByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M) (*mongo.DeleteResult, error)
Deletes one or many document by the informed filter
func DeleteOneByFilter ¶ added in v1.5.0
func DeleteOneByFilter(client *mongo.Client, dbName string, collectionName string, filter bson.M) (*mongo.DeleteResult, error)
Deletes one document by the informed filter
func DeleteOneByID ¶ added in v1.5.0
func DeleteOneByID(client *mongo.Client, dbName string, collectionName string, insertedID interface{}) (*mongo.DeleteResult, error)
Deletes a document by the informed ID
func FindAll ¶ added in v1.5.0
func FindAll(client *mongo.Client, dbName string, collectionName string, model interface{}, filter bson.M) (interface{}, error)
Find one or more documents by the provided filter
func FindOne ¶ added in v1.5.0
func FindOne(client *mongo.Client, dbName string, collectionName string, model interface{}, filter bson.M, findOption *options.FindOneOptions) (interface{}, error)
Find one document by the provided filter
func InsertMany ¶ added in v1.5.0
func InsertMany(client *mongo.Client, dbName string, collectionName string, models []interface{}) (*mongo.InsertManyResult, error)
Insert many documents
func InsertOne ¶ added in v1.5.0
func InsertOne(client *mongo.Client, dbName string, collectionName string, model interface{}) (*mongo.InsertOneResult, error)
Insert one document
func ReturnAuthenticatedClient ¶ added in v1.5.0
func ReturnAuthenticatedClient(url string, authDB string, user string, password string, appName string, createMonitor bool) (*mongo.Client, error)
Returns an authenticated mongodb client.
func ReturnAuthenticatedClientMongoAtlas ¶ added in v1.5.0
func ReturnAuthenticatedClientMongoAtlas(url string, user string, password string, db string, appName string, createMonitor bool) (*mongo.Client, error)
Return an autheticated mongodb client for Mongo Atlas
func ReturnClient ¶ added in v1.5.0
Returns a non-authenticated mongodb client.
func Total ¶
func Total(client *mongo.Client, dbName string, collectionName string, filter bson.M) (int64, error)
Returns the total number of documents in one collection
func UpdateByID ¶ added in v1.5.0
func UpdateByID(client *mongo.Client, dbName string, collectionName string, insertedID interface{}, updatedField interface{}) (*mongo.UpdateResult, error)
Update a document by the provided ID
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.