models

package
v0.0.0-...-a82cec0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2016 License: MIT Imports: 3 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'.

Index

Constants

View Source
const (
	// FictionBookType is the book_type for 'FICTION'.
	FictionBookType = BookType(1)

	// NonfictionBookType is the book_type for 'NONFICTION'.
	NonfictionBookType = BookType(2)
)

Variables

This section is empty.

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    // author_id
	Isbn     string // isbn
	Name     string // name
	Subject  string // subject
	// 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.

Looks up using index authors_pkey.

func AuthorByIsbn

func AuthorByIsbn(db XODB, isbn string) (*Author, error)

AuthorByIsbn retrieves a row from public.authors as a Author.

Looks up using index authors_isbn_key.

func AuthorsByName

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

AuthorsByName retrieves rows from public.authors, each as a Author.

Looks up using 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 Book

type Book struct {
	BookID   int      // book_id
	AuthorID int      // author_id
	Title    string   // title
	Booktype BookType // booktype
	Year     int      // year
	// 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.

Looks up using index books_pkey.

func BooksByTitle

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

BooksByTitle retrieves rows from public.books, each as a Book.

Looks up using index books_title_idx.

func (*Book) Author

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

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

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.

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 QueryOpt

type QueryOpt interface {
}

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