add comments

This commit is contained in:
lyx0 2022-08-12 02:50:45 +02:00
parent a2c9578b06
commit f241f2a816
2 changed files with 8 additions and 4 deletions

View file

@ -73,7 +73,6 @@ func main() {
app.Logger.Errorw("Missing room-id in message tag", app.Logger.Errorw("Missing room-id in message tag",
"roomId", roomId, "roomId", roomId,
) )
return return
} }
@ -87,7 +86,6 @@ func main() {
return return
} }
} }
}) })
// Received a WhisperMessage (Twitch DM). // Received a WhisperMessage (Twitch DM).

View file

@ -18,6 +18,9 @@ type ChannelModel struct {
DB *sql.DB DB *sql.DB
} }
// Get takes the login name for a channel and queries the database for an
// existing entry with that login value. If it exists it returns a
// pointer to a Channel.
func (c ChannelModel) Get(login string) (*Channel, error) { func (c ChannelModel) Get(login string) (*Channel, error) {
query := ` query := `
SELECT id, added_at, login, twitchid SELECT id, added_at, login, twitchid
@ -45,6 +48,7 @@ func (c ChannelModel) Get(login string) (*Channel, error) {
return &channel, nil return &channel, nil
} }
// Insert takes in a channel struct and inserts it into the database.
func (c ChannelModel) Insert(channel *Channel) error { func (c ChannelModel) Insert(channel *Channel) error {
query := ` query := `
INSERT INTO channels(login, twitchid) INSERT INTO channels(login, twitchid)
@ -75,7 +79,7 @@ func (c ChannelModel) Insert(channel *Channel) error {
return nil return nil
} }
// GetAll() returns a slice of all channels in the database. // GetAll() returns a pointer to a slice of all channels (`[]*Channel`) in the database.
func (c ChannelModel) GetAll() ([]*Channel, error) { func (c ChannelModel) GetAll() ([]*Channel, error) {
query := ` query := `
SELECT id, added_at, login, twitchid SELECT id, added_at, login, twitchid
@ -128,7 +132,7 @@ func (c ChannelModel) GetAll() ([]*Channel, error) {
return channels, nil return channels, nil
} }
// GetAll() returns a slice of all channels in the database. // GetJoinable() returns a slice of channel names (Channel.Login) in the database.
func (c ChannelModel) GetJoinable() ([]string, error) { func (c ChannelModel) GetJoinable() ([]string, error) {
query := ` query := `
SELECT login SELECT login
@ -178,6 +182,8 @@ func (c ChannelModel) GetJoinable() ([]string, error) {
return channels, nil return channels, nil
} }
// Delete takes in a login name and queries the database and if there is an
// entry with that login name deletes the entry.
func (c ChannelModel) Delete(login string) error { func (c ChannelModel) Delete(login string) error {
// Prepare the statement. // Prepare the statement.
query := ` query := `