postgres

package
v0.0.0-...-3991c3e Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(cfg env.Config) (*sql.DB, error)

OpenDB returns a new instance of DB associated with the given datasource name. caller should "defer db.Close()" after checking for error

Types

type Postgres

type Postgres interface {
	Ping(ctx context.Context) error
	AddUser(ctx context.Context, fullName string) (int, error)
	UserFullName(ctx context.Context, id int) (string, error)
}

Postgres holds the methods for the package

type Service

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

Service represents a service for managing records in the database

func NewService

func NewService(db *sql.DB) *Service

NewService creates a new Service

func (Service) AddUser

func (f Service) AddUser(ctx context.Context, fullName string) (int, error)

AddUser adds a new user

func (Service) Ping

func (f Service) Ping(ctx context.Context) error

Ping sends a SELECT 1 to the database as a connectivity test

func (Service) UserFullName

func (f Service) UserFullName(ctx context.Context, id int) (string, error)

UserFullName retrieves a user's FullName

Jump to

Keyboard shortcuts

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