storage

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	User                 string `json:"user"`
	Password             string `json:"password"`
	DbName               string `json:"dbname"`
	SSlMode              string `json:"sslmode,omitempty"`
	PoolMaxConns         string `json:"pool_max_conns,omitempty"`
	MasterHost           string `json:"master_host,omitempty"`
	MasterPort           string `json:"master_port,omitempty"`
	ReplicaHost          string `json:"replica_host,omitempty"`
	ReplicaPort          string `json:"replica_port,omitempty"`
	DefaultQueryExecMode string `json:"default_query_exec_mode,omitempty"`
	Schema               string `json:"schema"`
}

Config PostgreSQL Database Connection Parameters.

func (*Config) MasterConn added in v0.2.0

func (c *Config) MasterConn(ctx context.Context) (*pgxpool.Pool, error)

MasterConn connection without a "read-only transaction" check for master host database.

func (*Config) Migrate

func (c *Config) Migrate(path string) *Migration

Migrate creates a new configuration for database migration.

func (*Config) ReliableConn added in v0.2.0

func (c *Config) ReliableConn(ctx context.Context) (*pgxpool.Pool, error)

ReliableConn connection with a "read-only transaction" check. Returning master or replica pool connect.

func (*Config) ReplicaConn added in v0.2.0

func (c *Config) ReplicaConn(ctx context.Context) (*pgxpool.Pool, error)

ReplicaConn connection without a "read-only transaction" check for replica host database.

type Connection added in v0.2.2

type Connection struct {
	Columns       []string
	StorageConfig *Config
	TableName     string
	Timeout       int
}

Connection PostgreSQL connection parameters for performing ORM operations on a table.

func (*Connection) New added in v0.2.2

func (c *Connection) New() (*Orm, error)

New connection for operations on an ORM-style table, uses a reliable connection to the database.

type Migration

type Migration struct {
	Driver    string
	DBString  string
	DirString string
}

Migration config for database new migration.

func (*Migration) Down added in v0.2.9

func (m *Migration) Down()

Down performing drop operations.

func (*Migration) Up added in v0.2.9

func (m *Migration) Up()

Up creating or modifying a table in the database.

type Orm added in v0.2.13

type Orm struct {
	Table        string
	KeyField     string
	PageSize     string
	PageIndex    string
	Columns      []string
	Pool         *pgxpool.Pool
	StartDate    time.Time
	EndTime      time.Time
	AfterMinutes int
	Timeout      int
}

Orm table parameters for ORM implementation

func (*Orm) Delete added in v0.2.13

func (o *Orm) Delete() string

Delete will create a raw query sql string DELETE FROM <table> WHERE <id>=KeyField.

func (*Orm) Insert added in v0.2.13

func (o *Orm) Insert() string

Insert will create a raw query sql string "INSERT INTO <table> (column1, column2 ...) VALUES ($1, $2 ...)".

func (*Orm) OnConflictDoUpdate added in v0.2.13

func (o *Orm) OnConflictDoUpdate() string

OnConflictDoUpdate will create a raw query sql string "ON CONFLICT <id key> DO UPDATE SET <column=$1>, <column=$2> ..."

func (*Orm) SelectAllColumns added in v0.2.13

func (o *Orm) SelectAllColumns() string

SelectAllColumns will create a raw query sql string "SELECT * FROM <my_table>".

func (*Orm) SelectWhereParam added in v0.2.13

func (o *Orm) SelectWhereParam(param string) string

SelectWhereParam will create a raw query sql string "SELECT * FROM <table> WHERE <column=param>".

func (*Orm) Update added in v0.2.13

func (o *Orm) Update() string

Update will create a raw query sql string "UPDATE SET <column=$1>, <column=$2> ...".

Jump to

Keyboard shortcuts

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