Documentation ¶
Overview ¶
Package sqlserver contains generated code for schema 'booktest'.
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 DB
- type ErrInsertFailed
- type ErrUpdateFailed
- type ErrUpsertFailed
- type Error
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 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 'booktest.authors'.
func AuthorByAuthorID ¶
AuthorByAuthorID retrieves a row from 'booktest.authors' as a Author.
Generated from index 'authors_pkey'.
func AuthorsByName ¶
AuthorsByName retrieves a row from 'booktest.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 string `json:"book_tags"` // book_tags }
AuthorBookResult is the result of a search.
func AuthorBookResultsByTags ¶
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 Title string `json:"title"` // title Year int `json:"year"` // year Available time.Time `json:"available"` // available Description string `json:"description"` // description Tags string `json:"tags"` // tags // contains filtered or unexported fields }
Book represents a row from 'booktest.books'.
func BookByBookID ¶
BookByBookID retrieves a row from 'booktest.books' as a Book.
Generated from index 'books_pkey'.
func BookByISBN ¶
BookByISBN retrieves a row from 'booktest.books' as a Book.
Generated from index 'books_isbn_key'.
func BooksByTitleYear ¶
BooksByTitleYear retrieves a row from 'booktest.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 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 'booktest'.
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 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.