kk_pg

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Disable    sSLMode = "disable"
	Require    sSLMode = "require"
	VerifyCA   sSLMode = "verify-ca"
	VerifyFull sSLMode = "verify-full"
)
View Source
const (
	UTC timeZone = "UTC"
)

Variables

View Source
var GormClient *gorm.DB

Functions

func CreateDB

func CreateDB(cfg *ConfigPG, dbName string)

func CreateTables

func CreateTables(cfg *ConfigPG, tableModels ...any)

func EnablePostGIS

func EnablePostGIS(cfg *ConfigPG)

EnablePostGIS https://postgis.net/documentation/getting_started/install_windows/enabling_postgis/ note the db must be connected with a specific dbName, usually in DSN only works on postgresql whit PostGIS installed

func GenQuery

func GenQuery(cfg *ConfigPG, models ...any)

func GenerateModelFromTable

func GenerateModelFromTable(cfg *ConfigPG, tableNames ...string)

GenerateModelFromTable empty tables will generate all tables of current database

Types

type ConfigPG

type ConfigPG struct {
	DSN         PostgresDSN
	LogFileName string
	DebugMode   bool
}

func (*ConfigPG) Check

func (c *ConfigPG) Check()

func (*ConfigPG) Close

func (c *ConfigPG) Close()

func (*ConfigPG) Copy

func (c *ConfigPG) Copy() *ConfigPG

func (*ConfigPG) Init

func (c *ConfigPG) Init()

Init if debugMode is true, slog will print log to stdout and do not write to file.

func (*ConfigPG) NewDefaultDB

func (c *ConfigPG) NewDefaultDB() *gorm.DB

type PostgresDSN

type PostgresDSN struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  sSLMode
	TimeZone timeZone
}

func (*PostgresDSN) GetDSN

func (x *PostgresDSN) GetDSN() string

type Uint64Array

type Uint64Array []uint64

Uint64Array todo replace to pgtype.Array[] https://github.com/jackc/pgx/pull/2020

func (*Uint64Array) Scan

func (a *Uint64Array) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Uint64Array) Value

func (a Uint64Array) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

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