basicmongo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMongoDBConnection

func InitMongoDBConnection(host string, port int, connectionMode string, refreshMode bool) *mgo.Session

InitMongoDBConnection return a session to the Mongo instances configured in input. If input is null connect to the default instances

func InsertData

func InsertData(User interface{}, session *mgo.Session, database, collection, username string) string

InsertData is used for insert a generic data into a collection It take in input the session, database and collection where insert the change

func PopulateCollectionList

func PopulateCollectionList(session *mgo.Session, dataServer *ServerData) error

PopulateCollectionList populate the list of Collections from the database list name in input. Populate the structure in input, just for test purpouse

func RemoveCollectionFromDB

func RemoveCollectionFromDB(session *mgo.Session, database string, collection string) error

RemoveCollectionFromDB is used for remove the collection in input from the db

func RemoveUser

func RemoveUser(session *mgo.Session, database, collection, username string) error

RemoveUser Remove a registered user from MongoDB

Types

type Collection

type Collection struct {
	Name     string
	Document []interface{}
}

Collection struct for DB

func GetCollectionsData

func GetCollectionsData(session *mgo.Session, database string) []Collection

GetCollectionsData is used for retrieve the list of Collections from the DB in input. It return a list of collection containing all the data [Used for test purpouse]

type Database

type Database struct {
	Name        string
	Collections []Collection
}

Database struct for DB

type ServerData

type ServerData struct {
	DatabaseList []Database
}

ServerData struct for manage DB

func InitServerData

func InitServerData(session *mgo.Session) *ServerData

InitServerData is used for retrieve the list of DBs name from the mongo instance in input. It fetch the list of DBs from the Mongo instance. Return a pointer to a structure for store and manipulate the data

Jump to

Keyboard shortcuts

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