Documentation ¶
Index ¶
- type MySQL
- func (m *MySQL) CreateShortlink(shortlinkToCreate *models.ShortlinkToCreate, user *models.User) bool
- func (m *MySQL) CreateUser(user *models.User) bool
- func (m *MySQL) DeleteShortlink(short string) (int64, error)
- func (m *MySQL) GetShortlink(short string) (models.Shortlink, error)
- func (m *MySQL) GetShortlinkList(user *models.User) ([]models.Shortlink, error)
- func (m *MySQL) GetUser(username string) (*models.User, error)
- func (m *MySQL) Init() error
- func (m *MySQL) IsShortlinkTaken(short string) bool
- func (m *MySQL) Open(config *config.Config) error
- func (m *MySQL) ValidateUser(user *models.User) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
Middleware for interacting with the MySQL database.
This implements the database.Database interface and, therefore, provides all methods defined in it.
func (*MySQL) CreateShortlink ¶
func (m *MySQL) CreateShortlink(shortlinkToCreate *models.ShortlinkToCreate, user *models.User) bool
Inserts the passed shortlink into the database and therefore finalizes its creation.
func (*MySQL) CreateUser ¶
Inserts the passed user into the database.
func (*MySQL) DeleteShortlink ¶
Revokes/deletes a shortlink from the database. The shortlink is identified by its unique part.
func (*MySQL) GetShortlink ¶
Obtains a shortlink from the database by it's unique part.
func (*MySQL) GetShortlinkList ¶
Returns a list of all the user's shortlinks.
func (*MySQL) Init ¶
Checks whether all needed tables exist and if not, it automatically creates them as well as an admin user.
func (*MySQL) IsShortlinkTaken ¶
Performs a DB lookup for the passed unique part of a shortlink and checks whether or not it is already taken by a shortlink
func (*MySQL) Open ¶
Opens a database connection that is safe for concurrent use as it utilizes a connection pool. Reference: https://pkg.go.dev/database/sql#Open