db

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ForecastsCollectionName = os.Getenv("MONGO_FORECASTS_COLLECTION_NAME")
	RefreshesCollectionName = os.Getenv("MONGO_REFRESHES_COLLECTION_NAME")
	DatabaseName            = os.Getenv("MONGO_DATABASE_NAME")
	WarningLogger           = log.New(os.Stdout, "WARNING: ", log.LUTC|log.Ltime|log.Lshortfile)
	InfoLogger              = log.New(os.Stdout, "INFO: ", log.LUTC|log.Ltime|log.Lshortfile)
	ErrorLogger             = log.New(os.Stdout, "ERROR: ", log.LUTC|log.Ltime|log.Lshortfile)
)

Functions

func ConnectToMongoInstace

func ConnectToMongoInstace() *mongo.Client

func GetAllForecasts

func GetAllForecasts(
	client *mongo.Client,
	mongoResponse *models.MongoResponse,
	limit int,
	offset int,
	filter bson.D,
) (int, error)

func GetForecastbyID

func GetForecastbyID(client *mongo.Client, forecast *models.Forecast, ID string) error

func GetLastRefresh

func GetLastRefresh(client *mongo.Client, refresh *models.Refresh) error

func InsertAllForecasts

func InsertAllForecasts(client *mongo.Client, forecasts []models.Forecast) (error, bool)

Insert all forecast to refrehs the data Return an error and wither or not it failed under cooldown (too many request)

func InsertRefresh

func InsertRefresh(client *mongo.Client, refresh models.Refresh) error

func Ping

func Ping(client *mongo.Client) error

Check the MongoDB connection

Types

This section is empty.

Jump to

Keyboard shortcuts

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