models

package
v0.0.0-...-c4a604a Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2020 License: MIT Imports: 8 Imported by: 0

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'.

Index

Constants

This section is empty.

Variables

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

XOLog provides the log func used by generated queries.

Functions

This section is empty.

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 'PK__authors__86516BCF5405736B'.

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 AuthorBookResultsByTags

func AuthorBookResultsByTags(db XODB, tags string) ([]*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
	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 'PK__books__490D1AE1FF72C354'.

func BookByIsbn

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

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

Generated from index 'UQ__books__99F9D0A4C07E1698'.

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 'FK__books__author_id__47DBAE45'.

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