Changes database initialization
This commit is contained in:
parent
c0b6ecbf1c
commit
ccc85259cb
3 changed files with 45 additions and 7 deletions
29
internal/database/feed.go
Normal file
29
internal/database/feed.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue