Documentation ¶
Overview ¶
Package postgres contains generated code for schema 'public'.
Index ¶
- func Errorf(s string, v ...interface{})
- func Logf(s string, v ...interface{})
- func SayHello(ctx context.Context, db DB, name string) (string, error)
- func SetErrorLogger(logger interface{})
- func SetLogger(logger interface{})
- type Author
- func (a *Author) Delete(ctx context.Context, db DB) error
- func (a *Author) Deleted() bool
- func (a *Author) Exists() bool
- func (a *Author) Insert(ctx context.Context, db DB) error
- func (a *Author) Save(ctx context.Context, db DB) error
- func (a *Author) Update(ctx context.Context, db DB) error
- func (a *Author) Upsert(ctx context.Context, db DB) error
- type AuthorBookResult
- type Book
- func (b *Book) Author(ctx context.Context, db DB) (*Author, error)
- func (b *Book) Delete(ctx context.Context, db DB) error
- func (b *Book) Deleted() bool
- func (b *Book) Exists() bool
- func (b *Book) Insert(ctx context.Context, db DB) error
- func (b *Book) Save(ctx context.Context, db DB) error
- func (b *Book) Update(ctx context.Context, db DB) error
- func (b *Book) Upsert(ctx context.Context, db DB) error
- type BookType
- type DB
- type ErrInsertFailed
- type ErrInvalidBookType
- type ErrUpdateFailed
- type ErrUpsertFailed
- type Error
- type NullBookType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
func Errorf(s string, v ...interface{})
Errorf logs an error message using the package error logger.
func SayHello ¶
SayHello calls the stored function 'public.say_hello(character varying) character varying' on db.
func SetErrorLogger ¶
func SetErrorLogger(logger interface{})
SetErrorLogger sets the package error logger. Valid logger types:
io.Writer func(string, ...interface{}) (int, error) // fmt.Printf func(string, ...interface{}) // log.Printf
Types ¶
type Author ¶
type Author struct { AuthorID int `json:"author_id"` // author_id Name string `json:"name"` // name // contains filtered or unexported fields }
Author represents a row from 'public.authors'.
func AuthorByAuthorID ¶
AuthorByAuthorID retrieves a row from 'public.authors' as a Author.
Generated from index 'authors_pkey'.
func AuthorsByName ¶
AuthorsByName retrieves a row from 'public.authors' as a Author.
Generated from index 'authors_name_idx'.
func (*Author) Deleted ¶
Deleted returns true when the Author has been marked for deletion from the database.
type AuthorBookResult ¶
type AuthorBookResult struct { AuthorID int `json:"author_id"` // author_id AuthorName string `json:"author_name"` // author_name BookID int `json:"book_id"` // book_id BookISBN string `json:"book_isbn"` // book_isbn BookTitle string `json:"book_title"` // book_title BookTags pq.StringArray `json:"book_tags"` // book_tags }
AuthorBookResult is the result of a search.
func AuthorBookResultsByTags ¶
func AuthorBookResultsByTags(ctx context.Context, db DB, tags pq.StringArray) ([]*AuthorBookResult, error)
AuthorBookResultsByTags runs a custom query, returning results as AuthorBookResult.
type Book ¶
type Book struct { BookID int `json:"book_id"` // book_id AuthorID int `json:"author_id"` // author_id ISBN string `json:"isbn"` // isbn BookType BookType `json:"book_type"` // book_type Title string `json:"title"` // title Year int `json:"year"` // year Available time.Time `json:"available"` // available Description string `json:"description"` // description Tags pq.StringArray `json:"tags"` // tags // contains filtered or unexported fields }
Book represents a row from 'public.books'.
func BookByBookID ¶
BookByBookID retrieves a row from 'public.books' as a Book.
Generated from index 'books_pkey'.
func BookByISBN ¶
BookByISBN retrieves a row from 'public.books' as a Book.
Generated from index 'books_isbn_key'.
func BooksByTitleYear ¶
BooksByTitleYear retrieves a row from 'public.books' as a Book.
Generated from index 'books_title_idx'.
func (*Book) Author ¶
Author returns the Author associated with the Book's (AuthorID).
Generated from foreign key 'books_author_id_fkey'.
func (*Book) Deleted ¶
Deleted returns true when the Book has been marked for deletion from the database.
type BookType ¶
type BookType uint16
BookType is the 'book_type' enum type from schema 'public'.
const ( // BookTypeFiction is the 'FICTION' book_type. BookTypeFiction BookType = 1 // BookTypeNonfiction is the 'NONFICTION' book_type. BookTypeNonfiction BookType = 2 )
BookType values.
func (BookType) MarshalText ¶
MarshalText marshals BookType into text.
func (*BookType) UnmarshalText ¶
UnmarshalText unmarshals BookType from text.
type DB ¶
type DB interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row }
DB is the common interface for database operations that can be used with types from schema 'public'.
This works with both database/sql.DB and database/sql.Tx.
type ErrInsertFailed ¶
type ErrInsertFailed struct {
Err error
}
ErrInsertFailed is the insert failed error.
func (*ErrInsertFailed) Error ¶
func (err *ErrInsertFailed) Error() string
Error satisfies the error interface.
func (*ErrInsertFailed) Unwrap ¶
func (err *ErrInsertFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type ErrInvalidBookType ¶
type ErrInvalidBookType string
ErrInvalidBookType is the invalid BookType error.
func (ErrInvalidBookType) Error ¶
func (err ErrInvalidBookType) Error() string
Error satisfies the error interface.
type ErrUpdateFailed ¶
type ErrUpdateFailed struct {
Err error
}
ErrUpdateFailed is the update failed error.
func (*ErrUpdateFailed) Error ¶
func (err *ErrUpdateFailed) Error() string
Error satisfies the error interface.
func (*ErrUpdateFailed) Unwrap ¶
func (err *ErrUpdateFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type ErrUpsertFailed ¶
type ErrUpsertFailed struct {
Err error
}
ErrUpsertFailed is the upsert failed error.
func (*ErrUpsertFailed) Error ¶
func (err *ErrUpsertFailed) Error() string
Error satisfies the error interface.
func (*ErrUpsertFailed) Unwrap ¶
func (err *ErrUpsertFailed) Unwrap() error
Unwrap satisfies the unwrap interface.
type Error ¶
type Error string
Error is an error.
const ( // ErrAlreadyExists is the already exists error. ErrAlreadyExists Error = "already exists" // ErrDoesNotExist is the does not exist error. ErrDoesNotExist Error = "does not exist" // ErrMarkedForDeletion is the marked for deletion error. ErrMarkedForDeletion Error = "marked for deletion" )
Error values.
type NullBookType ¶
NullBookType represents a null 'book_type' enum for schema 'public'.
func (*NullBookType) Scan ¶
func (nbt *NullBookType) Scan(v interface{}) error
Scan satisfies the sql.Scanner interface.