transmet/news/news.go

26 lines
524 B
Go
Raw Normal View History

package news
import (
"time"
"database/sql"
_ "github.com/lib/pq"
"fmt"
)
type News struct {
news_id int
Url string
Title string
2015-05-12 07:06:28 +02:00
Category_id int
Date time.Time
2015-05-12 07:06:28 +02:00
Notes string
}
func (news *News) Insert(db *sql.DB) error {
2015-05-12 07:06:28 +02:00
_, err := db.Exec("INSERT INTO news (url, title, category_id, notes) VALUES($1, $2, $3, $4)", news.Url, news.Title, news.Category_id, news.Notes );
if err != nil {
fmt.Println("Error inserting news: ", err)
return err
}
return nil
}