pgtype

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v1.6.0

func Register(ctx context.Context, conn RegisterConn) error

Types

type DBQuerier

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

func NewQuerier

func NewQuerier(ctx context.Context, conn genericConn) (*DBQuerier, error)

NewQuerier creates a DBQuerier that implements Querier.

func (*DBQuerier) FindAuthorByID

func (q *DBQuerier) FindAuthorByID(ctx context.Context, authorID pgtype.Int4) (FindAuthorByIDRow, error)

FindAuthorByID implements Querier.FindAuthorByID.

func (*DBQuerier) InsertAuthor

func (q *DBQuerier) InsertAuthor(ctx context.Context, firstName pgtype.Text, lastName pgtype.Text) (pgtype.Int4, error)

InsertAuthor implements Querier.InsertAuthor.

func (*DBQuerier) SelectInt4

func (q *DBQuerier) SelectInt4(ctx context.Context) (pgtype.Int4, error)

SelectInt4 implements Querier.SelectInt4.

func (*DBQuerier) SelectInt8

func (q *DBQuerier) SelectInt8(ctx context.Context) (pgtype.Int8, error)

SelectInt8 implements Querier.SelectInt8.

type FindAuthorByIDRow

type FindAuthorByIDRow struct {
	AuthorID  pgtype.Int4 `json:"author_id"`
	FirstName pgtype.Text `json:"first_name"`
	LastName  pgtype.Text `json:"last_name"`
	Suffix    pgtype.Text `json:"suffix"`
}

type Querier

type Querier interface {
	// FindAuthorById finds one (or zero) authors by ID.
	FindAuthorByID(ctx context.Context, authorID pgtype.Int4) (FindAuthorByIDRow, error)

	// InsertAuthor inserts an author by name and returns the ID.
	InsertAuthor(ctx context.Context, firstName pgtype.Text, lastName pgtype.Text) (pgtype.Int4, error)

	SelectInt8(ctx context.Context) (pgtype.Int8, error)

	SelectInt4(ctx context.Context) (pgtype.Int4, error)
}

Querier is a typesafe Go interface backed by SQL queries.

type RegisterConn added in v1.6.0

type RegisterConn interface {
	LoadType(ctx context.Context, typeName string) (*pgtype.Type, error)
	TypeMap() *pgtype.Map
}

Jump to

Keyboard shortcuts

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