mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add comments
This commit is contained in:
parent
4374119f4c
commit
e029110ec7
|
@ -18,6 +18,7 @@ type UserModel struct {
|
||||||
DB *sql.DB
|
DB *sql.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert inserts a user model into the database.
|
||||||
func (u UserModel) Insert(user *User) error {
|
func (u UserModel) Insert(user *User) error {
|
||||||
query := `
|
query := `
|
||||||
INSERT INTO users(login, twitchid, level)
|
INSERT INTO users(login, twitchid, level)
|
||||||
|
@ -48,6 +49,8 @@ func (u UserModel) Insert(user *User) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setlevel searches the database for a record with the provided login value
|
||||||
|
// and if that exists sets the level to the supplied level value.
|
||||||
func (u UserModel) SetLevel(login string, level int) error {
|
func (u UserModel) SetLevel(login string, level int) error {
|
||||||
query := `
|
query := `
|
||||||
UPDATE users
|
UPDATE users
|
||||||
|
@ -74,6 +77,7 @@ func (u UserModel) SetLevel(login string, level int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get searches the database for a login name and returns the user struct on success.
|
||||||
func (u UserModel) Get(login string) (*User, error) {
|
func (u UserModel) Get(login string) (*User, error) {
|
||||||
query := `
|
query := `
|
||||||
SELECT id, added_at, login, twitchid, level
|
SELECT id, added_at, login, twitchid, level
|
||||||
|
@ -102,6 +106,8 @@ func (u UserModel) Get(login string) (*User, error) {
|
||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete searches the database for a value with the supplied login name and if
|
||||||
|
// one exists deletes the record, returning any errors that might occur.
|
||||||
func (u UserModel) Delete(login string) error {
|
func (u UserModel) Delete(login string) error {
|
||||||
// Prepare the statement.
|
// Prepare the statement.
|
||||||
query := `
|
query := `
|
||||||
|
|
Loading…
Reference in a new issue