models

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: MIT Imports: 8 Imported by: 3

Documentation

Overview

Package models contains the types for schema 'booktest'.

Package models contains the types for schema 'booktest'.

Package models contains the types for schema 'booktest'.

Package models contains the types for schema 'booktest'.

Package models contains the types for schema 'booktest'.

Package models contains the types for schema 'booktest'.

Index

Constants

View Source
const (
	// BookTypeFiction is the 'FICTION' BookType.
	BookTypeFiction = BookType(1)

	// BookTypeNonfiction is the 'NONFICTION' BookType.
	BookTypeNonfiction = BookType(2)
)

Variables

View Source
var XOLog = func(string, ...interface{}) {}

XOLog provides the log func used by generated queries.

Functions

func SayHello

func SayHello(db XODB, v0 string) (string, error)

SayHello calls the stored procedure 'booktest.say_hello(text) text' on db.

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

func AuthorByAuthorID(db XODB, authorID int) (*Author, error)

AuthorByAuthorID retrieves a row from 'booktest.authors' as a Author.

Generated from index 'authors_author_id_pkey'.

func AuthorsByName

func AuthorsByName(db XODB, name string) ([]*Author, error)

AuthorsByName retrieves a row from 'booktest.authors' as a Author.

Generated from index 'authors_name_idx'.

func (*Author) Delete

func (a *Author) Delete(db XODB) error

Delete deletes the Author from the database.

func (*Author) Deleted

func (a *Author) Deleted() bool

Deleted provides information if the Author has been deleted from the database.

func (*Author) Exists

func (a *Author) Exists() bool

Exists determines if the Author exists in the database.

func (*Author) Insert

func (a *Author) Insert(db XODB) error

Insert inserts the Author to the database.

func (*Author) Save

func (a *Author) Save(db XODB) error

Save saves the Author to the database.

func (*Author) Update

func (a *Author) Update(db XODB) error

Update updates the Author in the database.

type AuthorBookResult

type AuthorBookResult struct {
	AuthorID   int    // author_id
	AuthorName string // author_name
	BookID     int    // book_id
	BookIsbn   string // book_isbn
	BookTitle  string // book_title
	BookTags   string // book_tags
}

AuthorBookResult is the result of a search.

func AuthorBookResultsByTag

func AuthorBookResultsByTag(db XODB, tag string) ([]*AuthorBookResult, error)

AuthorBookResultsByTag 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
	Tags      string    `json:"tags"`      // tags
	// contains filtered or unexported fields
}

Book represents a row from 'booktest.books'.

func BookByBookID

func BookByBookID(db XODB, bookID int) (*Book, error)

BookByBookID retrieves a row from 'booktest.books' as a Book.

Generated from index 'books_book_id_pkey'.

func BookByIsbn

func BookByIsbn(db XODB, isbn string) (*Book, error)

BookByIsbn retrieves a row from 'booktest.books' as a Book.

Generated from index 'isbn'.

func BooksByAuthorID

func BooksByAuthorID(db XODB, authorID int) ([]*Book, error)

BooksByAuthorID retrieves a row from 'booktest.books' as a Book.

Generated from index 'author_id'.

func BooksByTitleYear

func BooksByTitleYear(db XODB, title string, year int) ([]*Book, error)

BooksByTitleYear retrieves a row from 'booktest.books' as a Book.

Generated from index 'books_title_idx'.

func (*Book) Author

func (b *Book) Author(db XODB) (*Author, error)

Author returns the Author associated with the Book's AuthorID (author_id).

Generated from foreign key 'books_ibfk_1'.

func (*Book) Delete

func (b *Book) Delete(db XODB) error

Delete deletes the Book from the database.

func (*Book) Deleted

func (b *Book) Deleted() bool

Deleted provides information if the Book has been deleted from the database.

func (*Book) Exists

func (b *Book) Exists() bool

Exists determines if the Book exists in the database.

func (*Book) Insert

func (b *Book) Insert(db XODB) error

Insert inserts the Book to the database.

func (*Book) Save

func (b *Book) Save(db XODB) error

Save saves the Book to the database.

func (*Book) Update

func (b *Book) Update(db XODB) error

Update updates the Book in the database.

type BookType

type BookType uint16

BookType is the 'book_type' enum type from schema 'booktest'.

func (BookType) MarshalText

func (bt BookType) MarshalText() ([]byte, error)

MarshalText marshals BookType into text.

func (*BookType) Scan

func (bt *BookType) Scan(src interface{}) error

Scan satisfies the database/sql.Scanner interface for BookType.

func (BookType) String

func (bt BookType) String() string

String returns the string value of the BookType.

func (*BookType) UnmarshalText

func (bt *BookType) UnmarshalText(text []byte) error

UnmarshalText unmarshals BookType from text.

func (BookType) Value

func (bt BookType) Value() (driver.Value, error)

Value satisfies the sql/driver.Valuer interface for BookType.

type ScannerValuer

type ScannerValuer interface {
	sql.Scanner
	driver.Valuer
}

ScannerValuer is the common interface for types that implement both the database/sql.Scanner and sql/driver.Valuer interfaces.

type Slice

type Slice []ScannerValuer

Slice is a slice of ScannerValuers.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface for StringSlice.

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface for StringSlice.

type XODB

type XODB interface {
	Exec(string, ...interface{}) (sql.Result, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
}

XODB is the common interface for database operations that can be used with types from schema 'booktest'.

This should work with database/sql.DB and database/sql.Tx.

Jump to

Keyboard shortcuts

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