pg

package
v0.0.0-...-bf444b6 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database represents a Postgres database, wrapping a postgres connection.

func NewDatabase

func NewDatabase(opts ...DatabaseOption) (*Database, error)

NewDatabase creates a new Postgres database.

func (*Database) Close

func (db *Database) Close() error

Close closes the database connection.

func (*Database) GetPool

func (db *Database) GetPool() Pool

GetPool returns the database pool.

func (*Database) Ping

func (db *Database) Ping(ctx context.Context) error

Ping checks the database connection.

type DatabaseOption

type DatabaseOption func(*Database) error

DatabaseOption configures a Postgres database.

func WithDatabaseLogger

func WithDatabaseLogger(logger log.Logger) DatabaseOption

WithDatabaseLogger sets the logger for a Neo4j database.

func WithDatabasePool

func WithDatabasePool(pool Pool) DatabaseOption

WithDatabasePool sets the pool for a Postgres database.

func WithDatabaseTracer

func WithDatabaseTracer(tracer tracing.Tracer) DatabaseOption

WithDatabaseTracer sets the tracer for a Neo4j database.

type NotificationRepository

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

NotificationRepository is a repository for managing notifications.

func NewNotificationRepository

func NewNotificationRepository(opts ...RepositoryOption) (*NotificationRepository, error)

NewNotificationRepository creates a new NotificationRepository.

func (*NotificationRepository) Create

func (r *NotificationRepository) Create(ctx context.Context, notification *model.Notification) error

func (*NotificationRepository) Delete

func (r *NotificationRepository) Delete(ctx context.Context, id, recipient model.ID) error

func (*NotificationRepository) Get

func (r *NotificationRepository) Get(ctx context.Context, id, recipient model.ID) (*model.Notification, error)

func (*NotificationRepository) GetAllByRecipient

func (r *NotificationRepository) GetAllByRecipient(ctx context.Context, recipient model.ID, offset, limit int) ([]*model.Notification, error)

func (*NotificationRepository) Update

func (r *NotificationRepository) Update(ctx context.Context, id, recipient model.ID, read bool) (*model.Notification, error)

type Pool

type Pool interface {
	Close()
	Acquire(ctx context.Context) (*pgxpool.Conn, error)
	AcquireFunc(ctx context.Context, f func(*pgxpool.Conn) error) error
	AcquireAllIdle(ctx context.Context) []*pgxpool.Conn
	Reset()
	Config() *pgxpool.Config
	Stat() *pgxpool.Stat
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
	Begin(ctx context.Context) (pgx.Tx, error)
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
	Ping(ctx context.Context) error
}

Pool defines the interface for a database connection pool.

func NewPool

NewPool creates a new Postgres pool.

type RepositoryOption

type RepositoryOption func(*baseRepository) error

func WithDatabase

func WithDatabase(db *Database) RepositoryOption

WithDatabase sets the baseRepository for a baseRepository.

func WithRepositoryLogger

func WithRepositoryLogger(logger log.Logger) RepositoryOption

WithRepositoryLogger sets the logger for a baseRepository.

func WithRepositoryTracer

func WithRepositoryTracer(tracer tracing.Tracer) RepositoryOption

WithRepositoryTracer sets the tracer for a baseRepository.

Jump to

Keyboard shortcuts

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