package
0.0.0-20221216201318-d63fd55bcbd4
Repository: https://github.com/byte-cats/datastation.git
Documentation: pkg.go.dev
# Functions
ApplyConfig sets the connection pool settings for a *sql.DB instance using the provided ConnectionConfig.
BeginPostgres starts a new transaction.
CheckDatabase checks if the Type, Protocol, Hostname, Port, Name, User, and Password fields in the given ConnectionConfig are set from the DATABASE_TYPE, DATABASE_PROTOCOL, DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, and DATABASE_PASSWORD environment variables.
CheckHostname checks if the Hostname field in the given ConnectionConfig is set from the DATABASE_HOST environment variable.
CheckName checks if the Name field in the given ConnectionConfig is set from the DATABASE_NAME environment variable.
CheckPassword checks if the Password field in the given ConnectionConfig is set from the DATABASE_PASSWORD environment variable.
CheckPort checks if the Port field in the given ConnectionConfig is set from the DATABASE_PORT environment variable.
CheckProtocol checks if the Protocol field in the given ConnectionConfig is set from the DATABASE_PROTOCOL environment variable.
CheckType checks if the Type field in the given ConnectionConfig is set from the DATABASE_TYPE environment variable.
CheckUsername checks if the User field in the given ConnectionConfig is set from the DATABASE_USER environment variable.
No description provided by the author
ClosePostgres closes the connection to the Postgres database.
ConnectMongoDB establishes a connection to a MongoDB server.
CreateMySqlTable creates a new table in the database based on the provided struct.
No description provided by the author
DefaultMongoDBConfig returns a default configuration for a MongoDB connection.
DefaultMysql returns a DatabaseConfig struct with default values for the fields.
DefaultMySqlConf returns a struct with default values for the fields.
No description provided by the author
No description provided by the author
DefaultRedisConfig returns a default configuration for a Redis connection.
DisconnectMongoDB closes the connection to a MongoDB server.
ExecPostgres executes a query that does not return rows (e.g.
ExecuteSQL is a generic function that can be used to execute any SQL query.
GetDatabase returns a ConnectionConfig struct with the Type, Protocol, Hostname, Port, Name, User, and Password fields set from the DATABASE_TYPE, DATABASE_PROTOCOL, DATABASE_HOST, DATABASE_PORT, DATABASE_NAME, DATABASE_USER, and DATABASE_PASSWORD environment variables.
MapToStruct converts a map[string]interface{} to a struct.
MongoDBOptions creates a *options.ClientOptions struct using a MongoDBConfig struct.
MongoDBPing pings the MongoDB server to test the connection.
MySqlConn establishes a connection to the database.
MySqlPingDB pings the database to check the connection.
MySqlString builds connection string for connecting to a MySQL database using the provided ConnectionConfig.
NewDBConnection establishes a connection to the MySQL database specified in the provided ConnectionConfig.
NewRedisClient creates a new Redis client using the provided configuration.
OpenPostgres opens a new connection to a Postgres database using the provided connection string.
PingPostgres pings the Postgres database to test the connection.
PostgresString returns a connection string for a Postgres database.
QueryPostgres executes a query that returns rows (e.g.
QueryRowPostgres executes a query that returns a single row.
QuerySQL is a generic function that can be used to execute any SELECT SQL query.
RedisClose closes the connection to the Redis server.
RedisDelete deletes a key in Redis.
RedisExists checks if a key exists in Redis.
RedisGet gets the value of a key in Redis.
RedisHExists checks if a field exists in a hash in Redis.
RedisHGet gets the value of a field in a hash in Redis.
RedisHSet sets the value of a field in a hash in Redis.
RedisOptions creates a *redis.Options struct using a RedisConfig struct.
RedisPing pings the Redis server to test the connection.
RedisSAdd adds a member to a set in Redis.
Set sets the value of a key in Redis.
SetupPostgres sets up a connection to a Postgres database using the provided configuration.
WithDBConnection establishes a connection to the database, creates the specified table if it doesn't exist, and then closes the connection when the provided function is finished executing.
# Structs
No description provided by the author
MongoDBConfig holds the configuration for a MongoDB connection.
MySqlDBConfig is a struct that contains the configuration for the database connection.
No description provided by the author