models

package
v0.0.0-...-33785bc Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package models contains the types for schema 'public'.

Package models contains the types for schema 'public'.

Package models contains the types for schema 'public'.

Package models contains the types for schema 'public'.

Package models contains the types for schema 'public'.

Package models contains the types for schema 'public'.

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

func AuthorByAuthorID

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

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

Generated from index 'authors_pkey'.

func AuthorsByName

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

AuthorsByName retrieves a row from 'public.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.

func (*Author) Upsert

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

Upsert performs an upsert for Author.

NOTE: PostgreSQL 9.5+ only

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   StringSlice // book_tags
}

AuthorBookResult is the result of a search.

func AuthorBookResultsByTags

func AuthorBookResultsByTags(db XODB, tags StringSlice) ([]*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:"booktype"`  // booktype
	Title     string      `json:"title"`     // title
	Year      int         `json:"year"`      // year
	Available time.Time   `json:"available"` // available
	Tags      StringSlice `json:"tags"`      // tags
	// contains filtered or unexported fields
}

Book represents a row from 'public.books'.

func BookByBookID

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

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

Generated from index 'books_pkey'.

func BookByIsbn

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

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

Generated from index 'books_isbn_key'.

func BooksByTitle

func BooksByTitle(db XODB, title string) ([]*Book, error)

BooksByTitle retrieves a row from 'public.books' as a Book.

Generated from index 'books_title_lower_idx'.

func BooksByTitleYear

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

BooksByTitleYear retrieves a row from 'public.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_author_id_fkey'.

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.

func (*Book) Upsert

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

Upsert performs an upsert for Book.

NOTE: PostgreSQL 9.5+ only

type BookType

type BookType uint16

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

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

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