Documentation ¶
Index ¶
- func ConnectDB(DatabaseType string, DatabaseConnection string, DatabaseName string)
- type DocDB
- func (doc *DocDB) ConnectMongoDB() (*DocDB, error)
- func (doc *DocDB) DeleteItemFromCollection(collectionname string, documentid string) error
- func (doc *DocDB) GetDefaultItembyName(collectionname string, name string) (bson.M, error)
- func (doc *DocDB) GetItembyID(collectionname string, id string) (bson.M, error)
- func (doc *DocDB) GetItembyUUID(collectionname string, uuid string) (bson.M, error)
- func (doc *DocDB) InsertCollection(collectionname string, idata interface{}) (*mongo.InsertOneResult, error)
- func (doc *DocDB) MonitorAndReconnect()
- func (doc *DocDB) QueryCollection(collectionname string, filter bson.M, projection bson.M) ([]bson.M, error)
- func (doc *DocDB) UpdateCollection(collectionname string, filter bson.M, update bson.M, idata interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*DocDB) ConnectMongoDB ¶
ConnectMongoDB establishes a connection to the MongoDB database. It returns a pointer to the DocDB struct and an error if any.
func (*DocDB) DeleteItemFromCollection ¶
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 ¶
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 (*DocDB) GetItembyUUID ¶
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.