Documentation ¶
Index ¶
- func NewPostgresDB(cfg *configs.DBConfig) (*sqlx.DB, error)
- type AuthorizationRepository
- type ImagesRepository
- type RepoInterface
- type Repository
- func (r *Repository) CreateUser(ctx context.Context, user models.User) (int, error)
- func (r *Repository) GetImageByID(ctx context.Context, id string) (models.Images, error)
- func (r *Repository) GetRequestFromID(ctx context.Context, userID int) ([]models.Request, error)
- func (r *Repository) GetUser(ctx context.Context, email string) (models.User, error)
- func (r *Repository) InsertImage(ctx context.Context, filename, format string) (string, error)
- func (r *Repository) RequestsHistory(ctx context.Context, sourceFormat, targetFormat, imageID, filename string, ...) (string, error)
- func (r *Repository) Transactional(f func(repo RepoInterface) error) error
- func (r *Repository) UpdateRequest(ctx context.Context, status, imageID, targetID string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthorizationRepository ¶
type AuthorizationRepository interface { CreateUser(ctx context.Context, user models.User) (int, error) GetUser(ctx context.Context, email string) (models.User, error) }
AuthorizationRepository interface contains database methods of the user.
type ImagesRepository ¶
type ImagesRepository interface { InsertImage(ctx context.Context, filename, format string) (string, error) RequestsHistory(ctx context.Context, sourceFormat, targetFormat, imageID, filename string, userID, ratio int) (string, error) GetRequestFromID(ctx context.Context, userID int) ([]models.Request, error) UpdateRequest(ctx context.Context, status, imageID, targetID string) error GetImageByID(ctx context.Context, id string) (models.Images, error) }
ImagesRepository interface contains database methods of images.
type RepoInterface ¶
type RepoInterface interface { AuthorizationRepository ImagesRepository Transactional(f func(repo RepoInterface) error) error }
RepoInterface contains AuthorizationRepository, ImagesRepository and Transactional func.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository struct provides access to the database.
func (*Repository) CreateUser ¶
CreateUser method is for inserting data into users table.
func (*Repository) GetImageByID ¶
GetImageByID gets id of the image.
func (*Repository) GetRequestFromID ¶
GetRequestFromID allows to get the history of users requests.
func (*Repository) InsertImage ¶
InsertImage inserts image to the database and returns image id.
func (*Repository) RequestsHistory ¶
func (r *Repository) RequestsHistory(ctx context.Context, sourceFormat, targetFormat, imageID, filename string, userID, ratio int) (string, error)
RequestsHistory add data to request table and returns request id.
func (*Repository) Transactional ¶
func (r *Repository) Transactional(f func(repo RepoInterface) error) error
Transactional func implement atomicity,it begins transactions,rollback and commit them.
func (*Repository) UpdateRequest ¶
func (r *Repository) UpdateRequest(ctx context.Context, status, imageID, targetID string) error
UpdateRequest updates request status.