Documentation
¶
Index ¶
- Variables
- func CompareHash(str, hash string) bool
- func Delete(db *model.Database, id uuid.UUID, uid uuid.UUID) (int, error)
- func GetApplicationColumns(db *model.Database, appId uuid.UUID) ([]string, error)
- func HashString(str string) string
- func Insert(db *model.Database, user *model.User) (int, error)
- func New(appId uuid.UUID, data *model.UserData) *model.User
- func Retrieve(db *model.Database, id uuid.UUID, uid uuid.UUID) (*map[string]string, int, error)
- func RetrieveAll(db *model.Database, id uuid.UUID) ([]map[string]string, int, error)
- func Update(db *model.Database, id uuid.UUID, uid uuid.UUID, data *model.UserData) (*model.User, int, error)
- func Validate(db *model.Database, appId uuid.UUID, user *model.User) (string, int, error)
- func ValidateLogin(db *model.Database, id uuid.UUID, columns []string, user *model.UserData) (*model.User, string, int, error)
Constants ¶
This section is empty.
Variables ¶
var COLUMNS = map[string]string{
"id": "ID",
"applicationid": "ApplicationID",
"username": "Username",
"first": "First",
"last": "Last",
"full": "Full",
"email": "Email",
"password": "Password",
"data": "Data",
"createdat": "CreatedAt",
"lastupdatedat": "LastUpdatedAt",
}
Define a map to store column names
Functions ¶
func CompareHash ¶
Compares the provided hash with the given string
func Delete ¶
Deletes a user from the database, ID should be parsed to a UUID to ensure its validity. The 'int' return on this function is the HTTP status code which should be sent back to the user upon calling this function.
func GetApplicationColumns ¶
Retrieves a list of the valid columns for an application based on the given ID.
func Insert ¶
Inserts a new user into the database. The 'int' return of this function is the HTTP status code that should be sent back to the user upon calling this function.
func RetrieveAll ¶
Retrieves all users from the database based on the given application ID.
func Update ¶
func Update(db *model.Database, id uuid.UUID, uid uuid.UUID, data *model.UserData) (*model.User, int, error)
Updates a user in the database. The 'id' parameter should be parsed into a UUID to ensure validity. Only provided parameters will be updated. The 'int' return of this function is the HTTP status code that should be sent back to the user upon calling this function.
func Validate ¶
Validates the user objects column inputs based on the application's columns. Returns a message and status code for use in the response.
func ValidateLogin ¶
func ValidateLogin(db *model.Database, id uuid.UUID, columns []string, user *model.UserData) (*model.User, string, int, error)
Validates a user's login credentials. The id parameter should be parsed to a UUID to ensure its validity. The columns parameter is a list of columns to be checked against the user's data. The user parameter is a pointer to a user model which contains the user's inputted data.
Types ¶
This section is empty.