Documentation ¶
Overview ¶
Package database contains methods used to perform CRUD operations to the MongoDB database
Package database contains methods used to perform CRUD operations to the MongoDB database
Index ¶
- type MongoDatabase
- func (md *MongoDatabase) ArchiveHost(hostname string) (*mongo.UpdateResult, utils.AdvancedErrorInterface)
- func (md *MongoDatabase) ConnectToMongodb()
- func (md *MongoDatabase) DeleteHostData(id primitive.ObjectID) utils.AdvancedErrorInterface
- func (md *MongoDatabase) FindOldArchivedHosts(t time.Time) ([]primitive.ObjectID, utils.AdvancedErrorInterface)
- func (md *MongoDatabase) FindOldCurrentHosts(t time.Time) ([]string, utils.AdvancedErrorInterface)
- func (md *MongoDatabase) FindPatchingFunction(hostname string) (model.PatchingFunction, utils.AdvancedErrorInterface)
- func (md *MongoDatabase) HistoricizeOracleDbsLicenses(licenses []dto.OracleDatabaseLicenseUsage) error
- func (md *MongoDatabase) Init()
- func (md *MongoDatabase) InsertHostData(hostData model.HostDataBE) (*mongo.InsertOneResult, utils.AdvancedErrorInterface)
- type MongoDatabaseInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoDatabase ¶
type MongoDatabase struct { // Config contains the dataservice global configuration Config config.Configuration // Client contain the mongodb client Client *mongo.Client // TimeNow contains a function that return the current time TimeNow func() time.Time // Log contains logger formatted Log *logrus.Logger }
MongoDatabase is a implementation
func (*MongoDatabase) ArchiveHost ¶
func (md *MongoDatabase) ArchiveHost(hostname string) (*mongo.UpdateResult, utils.AdvancedErrorInterface)
ArchiveHost archives tho host with hostname as hostname TODO return value, not mongo struct
func (*MongoDatabase) ConnectToMongodb ¶
func (md *MongoDatabase) ConnectToMongodb()
ConnectToMongodb connects to the MongoDB and return the connection
func (*MongoDatabase) DeleteHostData ¶
func (md *MongoDatabase) DeleteHostData(id primitive.ObjectID) utils.AdvancedErrorInterface
DeleteHostData delete the hostdata
func (*MongoDatabase) FindOldArchivedHosts ¶
func (md *MongoDatabase) FindOldArchivedHosts(t time.Time) ([]primitive.ObjectID, utils.AdvancedErrorInterface)
FindOldArchivedHosts return the list of archived hosts older than t
func (*MongoDatabase) FindOldCurrentHosts ¶
func (md *MongoDatabase) FindOldCurrentHosts(t time.Time) ([]string, utils.AdvancedErrorInterface)
FindOldCurrentHosts return the list of current hosts that haven't sent hostdata after time t
func (*MongoDatabase) FindPatchingFunction ¶
func (md *MongoDatabase) FindPatchingFunction(hostname string) (model.PatchingFunction, utils.AdvancedErrorInterface)
FindPatchingFunction find the the patching function associated to the hostname in the database
func (*MongoDatabase) HistoricizeOracleDbsLicenses ¶
func (md *MongoDatabase) HistoricizeOracleDbsLicenses(licenses []dto.OracleDatabaseLicenseUsage) error
func (*MongoDatabase) Init ¶
func (md *MongoDatabase) Init()
Init initializes the connection to the database
func (*MongoDatabase) InsertHostData ¶
func (md *MongoDatabase) InsertHostData(hostData model.HostDataBE) (*mongo.InsertOneResult, utils.AdvancedErrorInterface)
InsertHostData adds a new hostdata to the database TODO return value, not mongo struct
type MongoDatabaseInterface ¶
type MongoDatabaseInterface interface { // Init initializes the connection to the database Init() // ArchiveHost archives tho host with hostname as hostname ArchiveHost(hostname string) (*mongo.UpdateResult, utils.AdvancedErrorInterface) // InsertHostData adds a new hostdata to the database InsertHostData(hostData model.HostDataBE) (*mongo.InsertOneResult, utils.AdvancedErrorInterface) // FindOldCurrentHost return the list of current hosts that haven't sent hostdata after time t FindOldCurrentHosts(t time.Time) ([]string, utils.AdvancedErrorInterface) // FindOldArchivedHosts return the list of archived hosts older than t FindOldArchivedHosts(t time.Time) ([]primitive.ObjectID, utils.AdvancedErrorInterface) // DeleteHostData delete the hostdata DeleteHostData(id primitive.ObjectID) utils.AdvancedErrorInterface // FindPatchingFunction find the the patching function associated to the hostname in the database FindPatchingFunction(hostname string) (model.PatchingFunction, utils.AdvancedErrorInterface) HistoricizeOracleDbsLicenses(licenses []dto.OracleDatabaseLicenseUsage) error }
MongoDatabaseInterface is a interface that wrap methods used to perform CRUD operations in the mongodb database