Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Book ¶
type Book struct { gorm.Model // gorm.Model provides the fields ID, CreatedAt, UpdatedAt, and DeletedAt Title string `gorm:"size:191;not null;unique" json:"title"` Author string `gorm:"size:191;not null" json:"author"` Publisher string `gorm:"size:191;not null" json:"publisher"` Description string `gorm:"size:191;not null" json:"description"` }
Book is a struct that represents a book in the database
type File ¶
type File struct { gorm.Model // GORM model that contains the ID, CreatedAt, UpdatedAt, and DeletedAt fields Filename string `gorm:"not null"` // Filename of the file. Cannot be null. UUID string `gorm:"unique;not null"` // UUID of the file. Must be unique and cannot be null. }
File is a struct that represents a file in the database
type URL ¶
type URL struct { gorm.Model LongURL string `json:"long_url" gorm:"unique"` ShortURL string `json:"short_url" gorm:"unique"` AccessCount uint `json:"access_count"` LastAccessed *time.Time `json:"last_accessed"` AccessPlace string `json:"access_place"` }
URL is a struct that stores the information for a URL
func GetURLByShortURL ¶
GetURLByShortURL is a method used to get a URL from the database by its short URL It takes a string as a parameter and returns a URL struct and an error
func (*URL) GenerateShortURL ¶
func (u *URL) GenerateShortURL()
GenerateShortURL is a method used to generate a random short URL It takes no parameters and returns nothing
type User ¶
type User struct { gorm.Model ID uint `gorm:"primaryKey"` Name string `json:"name" binding:"required"` Email string `json:"email" binding:"required,email" gorm:"unique"` Password string `json:"password" binding:"required"` }
User defines the user in db User struct is used to store user information in the database
func (*User) CheckPassword ¶
CheckPassword checks user password CheckPassword takes a string as a parameter and compares it to the user's encrypted password It returns an error if there is an issue comparing the passwords
func (*User) CreateUserRecord ¶
CreateUserRecord creates a user record in the database CreateUserRecord takes a pointer to a User struct and creates a user record in the database It returns an error if there is an issue creating the user record
func (*User) HashPassword ¶
HashPassword encrypts user password HashPassword takes a string as a parameter and encrypts it using bcrypt It returns an error if there is an issue encrypting the password