Documentation ¶
Overview ¶
package mongo implements CRUD system with mongoDB NOTE: passing nil as the filter matches all documents in the collection
Index ¶
- func CloseClient(ctx context.Context) error
- func CreateMongoClient(uri, port string) (*mongo.Client, error)
- func DeleteOne(c *mongo.Collection, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func Find(c *mongo.Collection, filter, results []interface{}, ...) (*mongo.Cursor, error)
- func FindOne(c *mongo.Collection, filter, result interface{}, ...) error
- func GetCollection(database, collectionName string) *mongo.Collection
- func InsertMany(c *mongo.Collection, documents []interface{}, ...) (*mongo.InsertManyResult, error)
- func InsertOne(c *mongo.Collection, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func UpdateOne(c *mongo.Collection, filter, update interface{}, ...) (*mongo.UpdateResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseClient ¶
CloseClient checks if mongodb client if pingable and disconnects from database
func CreateMongoClient ¶
CreateClient creates client for mongodb server on uri+port and returns a pointer and an error
func DeleteOne ¶
func DeleteOne(c *mongo.Collection, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func Find ¶
func Find(c *mongo.Collection, filter, results []interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
Find finds all documents that match filter and returns error result is a pointer
func FindOne ¶
func FindOne(c *mongo.Collection, filter, result interface{}, opts ...*options.FindOneOptions) error
FindOne finds single value in the database and returns error result is a pointer
func GetCollection ¶
func GetCollection(database, collectionName string) *mongo.Collection
GetCollection gets collection with a collectionName from database
func InsertMany ¶
func InsertMany(c *mongo.Collection, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
func InsertOne ¶
func InsertOne(c *mongo.Collection, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func UpdateOne ¶
func UpdateOne(c *mongo.Collection, filter, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.