postgres

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 6 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 {
	Host     string
	Port     int
	Database string
	Username string
	Password string
	SSLMode  string
	MaxConns int32
	MinConns int32
}

Config holds PostgreSQL configuration

type PostgresAdapter

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

PostgresAdapter implements the Adapter interface for PostgreSQL

func New

func New(ctx context.Context, cfg *Config) (*PostgresAdapter, error)

New creates a new PostgreSQL adapter

func (*PostgresAdapter) Close

func (p *PostgresAdapter) Close() error

Close closes the connection pool

func (*PostgresAdapter) Count

func (p *PostgresAdapter) Count(ctx context.Context, query *core.Query) (int64, error)

Count counts records matching the query

func (*PostgresAdapter) Create

func (p *PostgresAdapter) Create(ctx context.Context, model string, data map[string]interface{}) (map[string]interface{}, error)

Create creates a new record

func (*PostgresAdapter) Delete

func (p *PostgresAdapter) Delete(ctx context.Context, query *core.Query) error

Delete deletes a single record matching the query

func (*PostgresAdapter) DeleteMany

func (p *PostgresAdapter) DeleteMany(ctx context.Context, query *core.Query) (int64, error)

DeleteMany deletes all records matching the query

func (*PostgresAdapter) FindMany

func (p *PostgresAdapter) FindMany(ctx context.Context, query *core.Query) ([]map[string]interface{}, error)

FindMany finds all records matching the query

func (*PostgresAdapter) FindOne

func (p *PostgresAdapter) FindOne(ctx context.Context, query *core.Query) (map[string]interface{}, error)

FindOne finds a single record matching the query

func (*PostgresAdapter) ID

func (p *PostgresAdapter) ID() string

ID returns the adapter identifier

func (*PostgresAdapter) Ping

func (p *PostgresAdapter) Ping(ctx context.Context) error

Ping checks the connection

func (*PostgresAdapter) Transaction

func (p *PostgresAdapter) Transaction(ctx context.Context, fn func(core.Adapter) error) error

Transaction executes a function in a transaction

func (*PostgresAdapter) Update

func (p *PostgresAdapter) Update(ctx context.Context, query *core.Query, data map[string]interface{}) (map[string]interface{}, error)

Update updates a single record matching the query

func (*PostgresAdapter) UpdateMany

func (p *PostgresAdapter) UpdateMany(ctx context.Context, query *core.Query, data map[string]interface{}) (int64, error)

UpdateMany updates all records matching the query

Jump to

Keyboard shortcuts

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