Documentation
¶
Index ¶
- func ClipCount(db *sql.DB, userID int64) (count int64, err error)
- func CloseConnection(db *sql.DB)
- func CreateConnection() (db *sql.DB, err error)
- func DeleteClips(db *sql.DB, userID int64) (err error)
- func GetPasswordHash(db *sql.DB, username string) (hash string, err error)
- func GetUserID(db *sql.DB, username string) (userID int64, err error)
- func InsertClip(db *sql.DB, c Data) (clipID int64, err error)
- func InsertPasswordHash(db *sql.DB, username, hashPassword string) (err error)
- func InsertUser(db *sql.DB, username string) (userID int64, err error)
- func SelectByUsername(db *sql.DB, username string) (userID int64, err error)
- type Data
- type Users
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClipCount ¶
ClipCount returns the number of clips for a user. Returns -1 if the user doesn't exist or has 0 clips.
func CloseConnection ¶
CloseConnection closes the connection to the database. Use defer CloseConnection below CreateConnection.
func CreateConnection ¶
CreateConnection creates a connection to the database. Add CloseConnection in the next line.
func DeleteClips ¶
DeleteClips deletes all the clips of a user.
func GetPasswordHash ¶
GetPasswordHash fetches the hash from the database.
func InsertClip ¶
InsertClip inserts a clip into the database and returns clipid.
func InsertPasswordHash ¶
InsertPasswordHash inserts the password hash in the database.
func InsertUser ¶
InsertUser inserts a new user into the database and returns a userID. userID is -1 if it already exists.
Types ¶
type Data ¶
type Data struct { UserID int64 `json:"userID"` Username string `json:"username"` MessageID int64 `json:"clipID"` Message string `json:"message" binding:"required"` Secret *bool `json:"secret" binding:"required"` }
Data is the data structure for clip data. This is used for storing and retrieving clips.
type Users ¶
type Users struct { Username string `json:"username" binding:"required"` Password string `json:"password" binding:"required"` PCount int `json:"pCount" binding:"required"` SPCount int `json:"spCount" binding:"required"` }
Users is the data structure for user data. This is used for authentication. It has addational fields such as PasswordCount- Pcount & SaltedPasswordCount- SPcount. These are used to check if the password has been changed or not