Documentation
¶
Index ¶
- func Register(ctx context.Context, conn RegisterConn) error
- type Author
- type Book
- type DBQuerier
- func (q *DBQuerier) AssignAuthor(ctx context.Context, authorID int32, bookID int32) (pgconn.CommandTag, error)
- func (q *DBQuerier) FindBooks(ctx context.Context) ([]FindBooksRow, error)
- func (q *DBQuerier) InsertAuthor(ctx context.Context, firstName string, lastName string) (int32, error)
- func (q *DBQuerier) InsertBook(ctx context.Context, title string) (int32, error)
- type FindBooksRow
- type Querier
- type RegisterConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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.
type FindBooksRow ¶
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.
Click to show internal directories.
Click to hide internal directories.