Changes database initialization

This commit is contained in:
Dennis Schoepf 2024-09-03 19:49:03 +02:00
parent c0b6ecbf1c
commit ccc85259cb
3 changed files with 45 additions and 7 deletions

29
internal/database/feed.go Normal file
View file

@ -0,0 +1,29 @@
package database
type FeedType string
const (
RSS FeedType = "RSS"
)
type Feed struct {
Name string
Url string
FeedType FeedType
}
func (f Feed) Insert() (int64, error) {
result, err := db.Exec("INSERT INTO feed (name, url, type) VALUES (?,?,?)", f.Name, f.Url, f.FeedType)
if err != nil {
return 0, err
}
id, err := result.LastInsertId()
if err != nil {
return 0, err
}
return id, nil
}