Documentation ¶
Index ¶
- Constants
- func GetLazyPaginatedResponsePG[V any](storage *PostgresqlStorage, r *http.Request, query string) ([]*V, error)
- type Book
- type BookReview
- type CreateBookReviewDto
- type PostgresqlStorage
- func (storage *PostgresqlStorage) CreateBookReview(createUserDto *CreateBookReviewDto) (*BookReview, error)
- func (storage *PostgresqlStorage) CreateUser(first_name, last_name, email, password string) (*User, error)
- func (storage *PostgresqlStorage) DeleteBookById(id int) error
- func (storage *PostgresqlStorage) DeleteBookReviewById(id int) error
- func (storage *PostgresqlStorage) DeleteUserById(id int) error
- func (storage *PostgresqlStorage) GetBookById(id int) (*Book, error)
- func (storage *PostgresqlStorage) GetBookReviewById(id int) (*BookReview, error)
- func (storage *PostgresqlStorage) GetBookReviews(r *http.Request) ([]*BookReview, error)
- func (storage *PostgresqlStorage) GetBookReviewsByBookId(id int, r *http.Request) ([]*BookReview, error)
- func (storage *PostgresqlStorage) GetBooks(r *http.Request) ([]*Book, error)
- func (storage *PostgresqlStorage) GetRoleById(id int) (*Role, error)
- func (storage *PostgresqlStorage) GetUserByEmail(email string) (*User, error)
- func (storage *PostgresqlStorage) GetUserById(id int) (*User, error)
- func (storage *PostgresqlStorage) GetUsers(r *http.Request) ([]*User, error)
- func (storage *PostgresqlStorage) UpdateBookById(id int, payload *UpdateBookDto) (*Book, error)
- func (storage *PostgresqlStorage) UpdateBookReview(id int, updateBookReviewDto UpdateBookReviewDto) (*BookReview, error)
- func (storage *PostgresqlStorage) UpdateUserById(id int, payload *UpdateUserDto) (*User, error)
- func (storage *PostgresqlStorage) UpdateUserProfileImageUrl(id int, objectKey string) error
- type Role
- type Storage
- type UpdateBookDto
- type UpdateBookReviewDto
- type UpdateUserDto
- type User
Constants ¶
View Source
const DBContextKey contextKey = "db"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Book ¶
type Book struct { ID int `json:"id" db:"id"` Title string `json:"title" db:"title"` Author string `json:"author" db:"author"` Genre string `json:"genre" db:"genre"` PublicationDate time.Time `json:"publicationDate" db:"publication_date"` Publisher string `json:"publisher" db:"publisher"` ISBN string `json:"isbn" db:"isbn"` PageCount string `json:"pageCount" db:"page_count"` Language string `json:"language" db:"language"` Format string `json:"format" db:"format"` }
type BookReview ¶
type BookReview struct { ID int `json:"id" db:"id"` BookID int `json:"book_id" db:"book_id"` UserID int `json:"user_id" db:"user_id"` Score int `json:"score" db:"score"` Review string `json:"review" db:"review"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type CreateBookReviewDto ¶
type PostgresqlStorage ¶
type PostgresqlStorage struct {
// contains filtered or unexported fields
}
func GetPgStorageFromRequest ¶
func GetPgStorageFromRequest(r *http.Request) (*PostgresqlStorage, error)
func NewPostgresStorage ¶
func NewPostgresStorage() (*PostgresqlStorage, error)
func (*PostgresqlStorage) CreateBookReview ¶
func (storage *PostgresqlStorage) CreateBookReview(createUserDto *CreateBookReviewDto) (*BookReview, error)
func (*PostgresqlStorage) CreateUser ¶
func (storage *PostgresqlStorage) CreateUser(first_name, last_name, email, password string) (*User, error)
func (*PostgresqlStorage) DeleteBookById ¶
func (storage *PostgresqlStorage) DeleteBookById(id int) error
func (*PostgresqlStorage) DeleteBookReviewById ¶
func (storage *PostgresqlStorage) DeleteBookReviewById(id int) error
func (*PostgresqlStorage) DeleteUserById ¶
func (storage *PostgresqlStorage) DeleteUserById(id int) error
func (*PostgresqlStorage) GetBookById ¶
func (storage *PostgresqlStorage) GetBookById(id int) (*Book, error)
func (*PostgresqlStorage) GetBookReviewById ¶
func (storage *PostgresqlStorage) GetBookReviewById(id int) (*BookReview, error)
func (*PostgresqlStorage) GetBookReviews ¶
func (storage *PostgresqlStorage) GetBookReviews(r *http.Request) ([]*BookReview, error)
func (*PostgresqlStorage) GetBookReviewsByBookId ¶
func (storage *PostgresqlStorage) GetBookReviewsByBookId(id int, r *http.Request) ([]*BookReview, error)
func (*PostgresqlStorage) GetBooks ¶
func (storage *PostgresqlStorage) GetBooks(r *http.Request) ([]*Book, error)
func (*PostgresqlStorage) GetRoleById ¶
func (storage *PostgresqlStorage) GetRoleById(id int) (*Role, error)
func (*PostgresqlStorage) GetUserByEmail ¶
func (storage *PostgresqlStorage) GetUserByEmail(email string) (*User, error)
func (*PostgresqlStorage) GetUserById ¶
func (storage *PostgresqlStorage) GetUserById(id int) (*User, error)
func (*PostgresqlStorage) GetUsers ¶
func (storage *PostgresqlStorage) GetUsers(r *http.Request) ([]*User, error)
func (*PostgresqlStorage) UpdateBookById ¶
func (storage *PostgresqlStorage) UpdateBookById(id int, payload *UpdateBookDto) (*Book, error)
func (*PostgresqlStorage) UpdateBookReview ¶
func (storage *PostgresqlStorage) UpdateBookReview(id int, updateBookReviewDto UpdateBookReviewDto) (*BookReview, error)
func (*PostgresqlStorage) UpdateUserById ¶
func (storage *PostgresqlStorage) UpdateUserById(id int, payload *UpdateUserDto) (*User, error)
func (*PostgresqlStorage) UpdateUserProfileImageUrl ¶
func (storage *PostgresqlStorage) UpdateUserProfileImageUrl(id int, objectKey string) error
type Storage ¶
type Storage interface { GetUsers(r *http.Request) ([]*User, error) GetUserById(int) (*User, error) GetUserByEmail(string) (*User, error) CreateUser(firstName, lastName, email, password string) (*User, error) DeleteUserById(int) error GetRoleById(int) (*Role, error) UpdateUserProfileImageUrl(id int, objectKey string) error // Books GetBooks(r *http.Request) ([]*Book, error) // Book Reviews GetBookReviews(r *http.Request) ([]*BookReview, error) GetBookReviewById(id int) (*BookReview, error) DeleteBookReviewById(id int) error UpdateBookReview(id int, updateBookReviewDto UpdateBookReviewDto) (*BookReview, error) }
type UpdateBookDto ¶
type UpdateBookDto struct { Title string `json:"title" validate:"nonzero" db:"title"` Author string `json:"author" validate:"nonzero" db:"author"` Genre string `json:"genre" validate:"nonzero" db:"genre"` PublicationDate time.Time `json:"publicationDate" validate:"nonzero" db:"publication_date"` Publisher string `json:"publisher" validate:"nonzero" db:"publisher"` ISBN string `json:"isbn" validate:"nonzero" db:"isbn"` PageCount string `json:"pageCount" validate:"nonzero" db:"page_count"` Language string `json:"language" validate:"nonzero" db:"language"` Format string `json:"format" validate:"nonzero" db:"format"` }
type UpdateBookReviewDto ¶
type UpdateUserDto ¶
type User ¶
type User struct { ID int `json:"id" db:"id"` FirstName string `json:"first_name" db:"first_name"` LastName string `json:"last_name" db:"last_name"` Email string `json:"email" db:"email"` Password string `json:"password,omitempty" db:"password"` RoleId int `json:"role_id" db:"role_id"` ProfileImageUrl string `json:"profile_image_url" db:"profile_image_url"` CreatedAt time.Time `json:"created_at" db:"created_at"` }
Click to show internal directories.
Click to hide internal directories.