casting

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

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

Types

type Author

type Author struct {
	AuthorID  *int32  `json:"author_id"`
	FirstName *string `json:"first_name"`
	LastName  *string `json:"last_name"`
	Suffix    *string `json:"suffix"`
}

Author represents the Postgres composite type "author".

type Book

type Book struct {
	BookID   *int32  `json:"book_id"`
	Title    *string `json:"title"`
	AuthorID *int32  `json:"author_id"`
}

Book represents the Postgres composite type "book".

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) AssignAuthor

func (q *DBQuerier) AssignAuthor(ctx context.Context, authorID int32, bookID int32) (pgconn.CommandTag, error)

AssignAuthor implements Querier.AssignAuthor.

func (*DBQuerier) FindBooks

func (q *DBQuerier) FindBooks(ctx context.Context) ([]FindBooksRow, error)

FindBooks implements Querier.FindBooks.

func (*DBQuerier) InsertAuthor

func (q *DBQuerier) InsertAuthor(ctx context.Context, firstName string, lastName string) (int32, error)

InsertAuthor implements Querier.InsertAuthor.

func (*DBQuerier) InsertBook

func (q *DBQuerier) InsertBook(ctx context.Context, title string) (int32, error)

InsertBook implements Querier.InsertBook.

type FindBooksRow

type FindBooksRow struct {
	A *Author `json:"a"`
	B *Book   `json:"b"`
}

type Querier

type Querier interface {
	// FindBooks finds all books.
	FindBooks(ctx context.Context) ([]FindBooksRow, error)

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

	// InsertBook inserts a book.
	InsertBook(ctx context.Context, title string) (int32, error)

	// AssignAuthor assigns an author to a book.
	AssignAuthor(ctx context.Context, authorID int32, bookID int32) (pgconn.CommandTag, error)
}

Querier is a typesafe Go interface backed by SQL queries.

type RegisterConn

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