Documentation ¶
Index ¶
- func Add(collection *mongo.Collection, data map[string]interface{}) (string, error)
- func CreateMongoClient(service string) (*mongo.Client, error)
- func GetAll(collection *mongo.Collection) ([]map[string]interface{}, error)
- func Remove(collection *mongo.Collection, filter map[string]interface{}) (interface{}, error)
- func RemoveByID(collection *mongo.Collection, ID string) (interface{}, error)
- func Update(collection *mongo.Collection, filter map[string]interface{}, ...) (interface{}, error)
- func UpdateByID(collection *mongo.Collection, ID string, update map[string]interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(collection *mongo.Collection, data map[string]interface{}) (string, error)
Add inserts a JSON document into a collection and returns the document ID.
func CreateMongoClient ¶
CreateMongoClient creates a new MongoDB client and establishes a connection
func GetAll ¶
func GetAll(collection *mongo.Collection) ([]map[string]interface{}, error)
GetAll returns all documents in the collection given.
func Remove ¶
func Remove(collection *mongo.Collection, filter map[string]interface{}) (interface{}, error)
Remove deletes a document from a collection based on the filter JSON.
func RemoveByID ¶
func RemoveByID(collection *mongo.Collection, ID string) (interface{}, error)
Remove deletes a document from a collection based on the document ID.
func Update ¶
func Update(collection *mongo.Collection, filter map[string]interface{}, update map[string]interface{}) (interface{}, error)
Update edits a document in a collection based on the filter JSON. It currently sets every field given in the update JSON, meaning it will overwrite arrays and nested structures with whatever is provided.
func UpdateByID ¶
func UpdateByID(collection *mongo.Collection, ID string, update map[string]interface{}) (interface{}, error)
Update edits a document in a collection based on the document ID. It currently sets every field given in the update JSON, meaning it will overwrite arrays and nested structures with whatever is provided.
Types ¶
This section is empty.