Documentation
¶
Index ¶
- func ScanReturnedBooks(rows *sql.Rows) ([]v1.Book, error)
- func ScanReturnedCollections(rows *sql.Rows) ([]v1.Collection, error)
- func ScanReturnedId(rows *sql.Rows) (*int, error)
- type PgDb
- func (pg *PgDb) BookCreate(b *v1.Book) (*int, error)
- func (pg *PgDb) BookFilter(title *string, genre *string, edition *int) ([]v1.Book, error)
- func (pg *PgDb) BookGet(id int) (*v1.Book, error)
- func (pg *PgDb) BookRemove(id int) error
- func (pg *PgDb) CollectionCreate(title *string, bookIds []int) (*string, error)
- func (pg *PgDb) CollectionGet(title *string) (*v1.Collection, error)
- func (pg *PgDb) CollectionRemove(title *string) error
- func (pg *PgDb) Connect() error
- func (pg *PgDb) CreateAuthorIfNew(b *v1.Book) (*int, error)
- func (pg *PgDb) GetAuthorByName(b *v1.Book) (*v1.Author, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScanReturnedBooks ¶
Returns a series of books returned by rows. Returns an empty array if no rows returned.
func ScanReturnedCollections ¶
func ScanReturnedCollections(rows *sql.Rows) ([]v1.Collection, error)
Scans rows for one row expecting one integer parameter. Returns nil, nil for no rows returned or nil rows pointer.
Types ¶
type PgDb ¶
type PgDb struct {
SqlDb *sql.DB
SchemaVersion string // Used for migrations
Config db.ConnectionConfig
}
The struct for PgDb that
func (*PgDb) BookCreate ¶
Creates a new book in the database. Returns the book_id generated.
func (*PgDb) BookFilter ¶
Returns an array of books based on filter. If no filters given, this function returns all books. Title and genre are wildcard searches, edition is equality.
func (*PgDb) BookRemove ¶
Removes a book from the database based on ID.
func (*PgDb) CollectionCreate ¶
func (*PgDb) CollectionGet ¶
func (pg *PgDb) CollectionGet(title *string) (*v1.Collection, error)
func (*PgDb) CollectionRemove ¶
func (*PgDb) CreateAuthorIfNew ¶
If an author does not exist (i.e., first_name and last_name found in database) create it. Returns the created or existing author_id.
Click to show internal directories.
Click to hide internal directories.