postgresql

package
v0.0.0-...-3c459cb Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanReturnedBooks

func ScanReturnedBooks(rows *sql.Rows) ([]v1.Book, error)

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.

func ScanReturnedId

func ScanReturnedId(rows *sql.Rows) (*int, 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

func (pg *PgDb) BookCreate(b *v1.Book) (*int, error)

Creates a new book in the database. Returns the book_id generated.

func (*PgDb) BookFilter

func (pg *PgDb) BookFilter(title *string, genre *string, edition *int) ([]v1.Book, error)

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

func (pg *PgDb) BookGet(id int) (*v1.Book, error)

Returns a book from the database based on id.

func (*PgDb) BookRemove

func (pg *PgDb) BookRemove(id int) error

Removes a book from the database based on ID.

func (*PgDb) CollectionCreate

func (pg *PgDb) CollectionCreate(title *string, bookIds []int) (*string, error)

func (*PgDb) CollectionGet

func (pg *PgDb) CollectionGet(title *string) (*v1.Collection, error)

func (*PgDb) CollectionRemove

func (pg *PgDb) CollectionRemove(title *string) error

func (*PgDb) Connect

func (pg *PgDb) Connect() error

func (*PgDb) CreateAuthorIfNew

func (pg *PgDb) CreateAuthorIfNew(b *v1.Book) (*int, error)

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.

func (*PgDb) GetAuthorByName

func (pg *PgDb) GetAuthorByName(b *v1.Book) (*v1.Author, error)

Gets an author by name (i.e., author.first_name & author.last_name full match). Returns nil, nil for no rows found or nil book pointer.

Jump to

Keyboard shortcuts

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