gomongo

package module
v0.0.0-...-53cc2e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 6 Imported by: 1

README

gomongo

Install

go get github.com/thinksystemio/package-gomongo

Documentation

Index

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

func CreateMongoClient(service string) (*mongo.Client, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL