Documentation
¶
Index ¶
- Variables
- func EnsureSchema(db *sql.DB) error
- func NewDB(dbPath string) (*sql.DB, error)
- func NewServer(dataBase *sql.DB, logger *zap.SugaredLogger, ...) *libraryServiceServer
- func RunGRPCGateway(ctx context.Context, log *zap.SugaredLogger, addr string, grpcAddr string, ...) error
- type Author
- type Book
- type DBStorage
- func (storage *DBStorage) DeleteBookFromDB(isbn string) error
- func (storage *DBStorage) FindSpecificBook(isbnToFind string) Book
- func (storage *DBStorage) InsertIntoDatabase(b Book) error
- func (storage *DBStorage) ReadDatabaseList() []Book
- func (storage *DBStorage) ReadRows(rows *sql.Rows, b []Book) []Book
Constants ¶
This section is empty.
Variables ¶
View Source
var (
LastNamePattern = regexp.MustCompile(`^[a-zA-Z]+(?:\s+[a-zA-Z]+)*$`)
)
The regex patterns for the validate function
Functions ¶
func EnsureSchema ¶
EnsureSchema runs migrations from the embedded filesystem against the provided database connection.
Types ¶
type Book ¶
type Book struct {
ISBN string `json:"isbn"` // The identification of the books
Title string `json:"title"`
CreateTime time.Time `json:"createTime"` // The time of creation of book instance
UpdateTime time.Time `json:"updateTime"` // The time of update for book instance
Publisher string `json:"publisher"`
Author Author `json:"author"` // Embedded author struct
}
Struct for the book properties.
func NewBookFromProto ¶
NewBookFromProto converts a *librarypb.Book which is on the proto fromat to the Book instance such that the database can deal with it.
type DBStorage ¶
type DBStorage struct {
// contains filtered or unexported fields
}
func (*DBStorage) DeleteBookFromDB ¶
Deletes a specific book from the database
func (*DBStorage) FindSpecificBook ¶
Reads from the database and find a specific book that exists.
func (*DBStorage) InsertIntoDatabase ¶
DatabaseQuery Prepers a database query and executes the query on the database. It takes as input a query string and gives as output the rows
func (*DBStorage) ReadDatabaseList ¶
ReadDatabase reads the information that we get from the database.
Directories
¶
| Path | Synopsis |
|---|---|
|
gen
|
|
|
proto/go/librarypb
Package librarypb is a reverse proxy.
|
Package librarypb is a reverse proxy. |
Click to show internal directories.
Click to hide internal directories.