lib

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteReadQuery

func ExecuteReadQuery(ctx context.Context, query string, conn *sql.Conn, lim int64) ([]map[string]any, error)

func ExecuteWriteQuery

func ExecuteWriteQuery(ctx context.Context, query string, conn *sql.Conn) (sql.Result, error)

func GenerateDBFieldMap

func GenerateDBFieldMap(doc any) map[string]reflect.Value

func GenerateDeleteQuery

func GenerateDeleteQuery(table, id string) string

func GenerateInsertQuery

func GenerateInsertQuery(tableName string, record map[string]any) string

func GenerateReadQuery

func GenerateReadQuery(tableName string, filter map[string]any) string

func GenerateTableName

func GenerateTableName(table interface{}) string

func GenerateUpdateQuery

func GenerateUpdateQuery(table string, id string, record map[string]any) string

func GenerateWhereClauseFromFilter

func GenerateWhereClauseFromFilter(filter any) string

func GenerateWhereClauseFromID

func GenerateWhereClauseFromID(id any) string

func GetPostgresConnection

func GetPostgresConnection(cfg PostgresConfig) (*sql.Conn, error)

func HandleSliceAny

func HandleSliceAny(v []any) string

func IsZeroValue

func IsZeroValue(value any) bool

func MapToRecord

func MapToRecord(record map[string]any) (*pb.RecordResponse, error)

func MapsToRecords

func MapsToRecords(records []map[string]any) (*pb.RecordsResponse, error)

func ScanSingleRow

func ScanSingleRow(rows *sql.Rows, fieldMap map[string]reflect.Value) error

func SyncTable

func SyncTable(ctx context.Context, conn *sql.Conn, table any) error

Types

type PostgresConfig

type PostgresConfig struct {
	Name     string `json:"name" yaml:"name"`
	Host     string `json:"host" yaml:"host"`
	Port     string `json:"port" yaml:"port"`
	User     string `json:"user" yaml:"user"`
	Password string `json:"password" yaml:"password"`
	SSLMode  string `json:"sslmode" yaml:"sslmode"`
}

func (PostgresConfig) String

func (cp PostgresConfig) String() string

type Statement

type Statement struct {
	// contains filtered or unexported fields
}

func (Statement) AddWhereClause

func (stmt Statement) AddWhereClause(cond string) string

func (Statement) AllCols

func (stmt Statement) AllCols() Statement

func (Statement) CheckWhereClauseNotEmpty

func (stmt Statement) CheckWhereClauseNotEmpty() error

func (Statement) Columns

func (stmt Statement) Columns(cols ...string) Statement

func (Statement) ExecuteInsertQuery

func (stmt Statement) ExecuteInsertQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string) (any, error)

func (Statement) ExecuteReadQuery

func (stmt Statement) ExecuteReadQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string, doc any) error

func (Statement) ExecuteWriteQuery

func (stmt Statement) ExecuteWriteQuery(ctx context.Context, conn *sql.Conn, tx *sql.Tx, query string) (sql.Result, error)

func (Statement) GenerateDeleteQuery

func (stmt Statement) GenerateDeleteQuery() string

func (Statement) GenerateInsertQuery

func (stmt Statement) GenerateInsertQuery(doc any) string

func (Statement) GenerateReadQuery

func (stmt Statement) GenerateReadQuery(doc any) string

func (Statement) GenerateUpdateQuery

func (stmt Statement) GenerateUpdateQuery(doc any) string

func (Statement) GenerateWhereClause

func (stmt Statement) GenerateWhereClause(filter ...any) Statement

func (Statement) ID

func (stmt Statement) ID(id any) Statement

func (Statement) In

func (stmt Statement) In(col string, values ...any) Statement

func (Statement) MustCols

func (stmt Statement) MustCols(cols ...string) Statement

func (Statement) ShowSQL

func (stmt Statement) ShowSQL(showSQL bool) Statement

func (Statement) Table

func (stmt Statement) Table(name string) Statement

func (Statement) Where

func (stmt Statement) Where(cond string, args ...any) Statement

Jump to

Keyboard shortcuts

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