models

package
v0.0.0-...-91607d9 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Connclient *mongo.Client

Connclient holds connection handle It is best practice to keep a client that is connected to MongoDB around so that the application can make use of connection pooling.

Functions

func CloseConnections

func CloseConnections()

CloseConnections will close all the connections in the end if your application no longer requires a connection, the connection can be closed with client.Disconnect()

func DeleteAllDoc

func DeleteAllDoc(dbName, collectionName, query string) int64

DeleteAllDoc will retune find results

func DeleteOneDoc

func DeleteOneDoc(dbName, collectionName, query string) int64

DeleteOneDoc will retune find results

func GetClient

func GetClient(connString string)

GetClient gives a MongoDB Client

func InsertManyDoc

func InsertManyDoc(trainer []interface{}, dbName, collectionName string) interface{}

InsertManyDoc insert a new document

func InsertOneDoc

func InsertOneDoc(trainer Trainer, dbName, collectionName string) interface{}

InsertOneDoc insert a new document

func UpdateAllDoc

func UpdateAllDoc(dbName, collectionName, updatedData, query string) int64

UpdateAllDoc update the info of a informed Hero

func UpdateOneDoc

func UpdateOneDoc(dbName, collectionName, updatedData, query string) int64

UpdateOneDoc update the info of a informed Hero

Types

type Trainer

type Trainer struct {
	Name string
	Age  int
	City string
}

Trainer struct represent a trainer details

func FindAllDocs

func FindAllDocs(dbName, collectionName, query string) []*Trainer

FindAllDocs return all documents from the collection Heroes

func FindOneDoc

func FindOneDoc(dbName, collectionName, query string) Trainer

FindOneDoc will retune find results

Jump to

Keyboard shortcuts

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