documents

package
v0.0.0-...-edbed3e Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(DatabaseType string, DatabaseConnection string, DatabaseName string)

Types

type DocDB

type DocDB struct {
	MongoDBClient        *mongo.Client
	MongoDBDatabase      *mongo.Database
	MongoDBCollection_TC *mongo.Collection
	/*
	 */
	DatabaseType       string
	DatabaseConnection string
	DatabaseName       string
	// contains filtered or unexported fields
}
var DocDBCon *DocDB

func InitMongoDB

func InitMongoDB(DatabaseConnection string, DatabaseName string) (*DocDB, error)

func (*DocDB) ConnectMongoDB

func (doc *DocDB) ConnectMongoDB() (*DocDB, error)

ConnectMongoDB establishes a connection to the MongoDB database. It returns a pointer to the DocDB struct and an error if any.

func (*DocDB) DeleteItemFromCollection

func (doc *DocDB) DeleteItemFromCollection(collectionname string, documentid string) error

DeleteItemFromCollection deletes an item from the specified collection by its ID. It takes the collection name and the ID as parameters. It returns an error if any. The function logs the performance duration and recovers from any panics. The function uses the MongoDB Go driver to delete the item from the collection.

func (*DocDB) GetDefaultItembyName

func (doc *DocDB) GetDefaultItembyName(collectionname string, name string) (bson.M, error)

GetDefaultItembyName retrieves the default item from the specified collection by name. It takes the collection name and the name of the item as input parameters. It returns the retrieved item as a bson.M object and an error if any. The function logs the performance duration and recovers from any panics. The function uses the MongoDB Go driver to query the collection.

func (*DocDB) GetItembyID

func (doc *DocDB) GetItembyID(collectionname string, id string) (bson.M, error)

func (*DocDB) GetItembyUUID

func (doc *DocDB) GetItembyUUID(collectionname string, uuid string) (bson.M, error)

func (*DocDB) InsertCollection

func (doc *DocDB) InsertCollection(collectionname string, idata interface{}) (*mongo.InsertOneResult, error)

func (*DocDB) MonitorAndReconnect

func (doc *DocDB) MonitorAndReconnect()

func (*DocDB) QueryCollection

func (doc *DocDB) QueryCollection(collectionname string, filter bson.M, projection bson.M) ([]bson.M, error)

QueryCollection queries a MongoDB collection with the specified filter and projection. It returns an array of documents that match the filter, along with any error that occurred. The function logs the performance duration and recovers from any panics. The function uses the MongoDB Go driver to query the collection.

func (*DocDB) UpdateCollection

func (doc *DocDB) UpdateCollection(collectionname string, filter bson.M, update bson.M, idata interface{}) error

GetItembyName retrieves an item from the specified collection by its name. It takes the collection name and the name as parameters. It returns the item as a bson.M object and an error if any. The function logs the performance duration and recovers from any panics. The function uses the MongoDB Go driver to query the collection.

Jump to

Keyboard shortcuts

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