xdb

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package xdb is a simple wrapper for gorm client creation, it will create a gorm.DB with options

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigFromAwsSecretsManager added in v0.0.2

func LoadConfigFromAwsSecretsManager(cfg *Config) error

LoadConfigFromAwsSecretsManager load config from aws secrets manager If you have multiple databases, you can manually call this function to load the config Otherwise, you can use the New function to load the config automatically(that will not change the config outside)

func New

func New(config Config) (*gorm.DB, error)

New creates a new postgres database connection

Types

type Config

type Config struct {
	SecretsManagerPath string
	Host               string
	Port               string
	Username           string
	Password           string
	Name               string
	TranslateError     bool `default:"true"`
	UseSlog            bool `default:"true"`
}

Config is the configuration for the postgres database If SecretsManagerPath is set (and Host not set), it will try to load the config from aws ssm parameter store, ignore other fields. But the Name field will override the DB Name field in SecretsManager value, if both are set.

Jump to

Keyboard shortcuts

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