adapters

package
v0.0.0-...-e771e73 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const SchemaId contextSchema = "schemaId"

Declaramos la constante con ese tipo

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions

type Actions uint8
const (
	NONE Actions = iota
	INSERT
	UPDATE
	DELETE
)

type ConfigPgxAdapter

type ConfigPgxAdapter struct {
	Host            string
	Database        string
	Schema          string
	User            string
	Password        string
	Port            string
	Ssl             string //disable,require
	AppName         string
	MaxConns        int32
	MinConns        int32
	MaxConnIdleTime time.Duration
}

type DataExec

type DataExec struct {
	Querys string
	Values []any
	Action Actions
}

type PgxAdapter

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

func NewPool

func NewPool(setting ConfigPgxAdapter) (*PgxAdapter, error)

func NewPoolWithConfig

func NewPoolWithConfig(setting ConfigPgxAdapter) (*PgxAdapter, error)

func (*PgxAdapter) Close

func (c *PgxAdapter) Close()

func (PgxAdapter) Execute

func (p PgxAdapter) Execute(ctx context.Context, sql string, args ...any) ([]map[string]any, error)

func (PgxAdapter) ExecuteTransactions

func (p PgxAdapter) ExecuteTransactions(ctx context.Context, dataExec ...DataExec) error

func (PgxAdapter) ExecuteTransactionsMulti

func (p PgxAdapter) ExecuteTransactionsMulti(ctx context.Context, dataExec ...[]DataExec) error

func (PgxAdapter) ExecuteTransactionsMultiWithSchema

func (p PgxAdapter) ExecuteTransactionsMultiWithSchema(schema string, ctx context.Context, dataExec ...[]DataExec) error

func (PgxAdapter) ExecuteTransactionsWithSchema

func (p PgxAdapter) ExecuteTransactionsWithSchema(schema string, ctx context.Context, dataExec ...DataExec) error

func (PgxAdapter) ExecuteWithPgxScan

func (p PgxAdapter) ExecuteWithPgxScan(ctx context.Context, dest any, sql string, args ...any) error

func (PgxAdapter) ExecuteWithPgxScanAndSchema

func (p PgxAdapter) ExecuteWithPgxScanAndSchema(schema string, ctx context.Context, dest any, sql string, args ...any) error

func (PgxAdapter) Pool

func (c PgxAdapter) Pool() *pgxpool.Pool

func (*PgxAdapter) Procedure

func (p *PgxAdapter) Procedure(ctx context.Context, sql string, arguments ...any) error

Procedure ejecuta una consulta de tipo procedimiento (por ejemplo, `CALL` o funciones sin retorno de datos) utilizando `pgx`.

Esta función está diseñada para ejecutar procedimientos almacenados u operaciones SQL que **no devuelven resultados** (solo efectos colaterales en la base de datos).

Comportamiento: - Si existe un error anterior (`q.err`), lo retorna inmediatamente sin ejecutar la consulta. - Desactiva el indicador `sessionActiva`, indicando que no se espera continuar usando la misma conexión. - Ejecuta la consulta generada con `getQuery()` y los argumentos acumulados. - Si ocurre un error al ejecutar, se almacena y se retorna. - Siempre cierra la conexión (`q.conn.Close()`) al finalizar.

Ejemplo de uso:

query := new(pgorm.Query).New(pgorm.QConfig{Database: "my_db"})
query.SetQueryString("CALL procesar_datos($1)").SetArgs(123).Procedure()

Retorna:

  • `nil` si la ejecución fue exitosa,
  • Un `error` si la ejecución falló o si ya existía un error previo en el estado del `Query`.

func (*PgxAdapter) ProcedureWithSchema

func (p *PgxAdapter) ProcedureWithSchema(schema string, ctx context.Context, sql string, arguments ...any) error

Jump to

Keyboard shortcuts

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