You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
770 B
35 lines
770 B
package main |
|
|
|
import ( |
|
"time" |
|
|
|
"gorm.io/gorm" |
|
) |
|
|
|
type Remind struct { |
|
ID int `json:"id" gorm:"primary_key"` |
|
Title string `json:"title"` |
|
DateTime time.Time `json:"datetime" gorm:"index"` |
|
Content string `json:"content"` |
|
} |
|
|
|
// Return a list of all the articles |
|
func getAllReminds() ([]Remind, error) { |
|
var reminds []Remind |
|
result := DB.Find(&reminds) |
|
if err := result.Error; err != nil { |
|
return nil, err |
|
} |
|
return reminds, nil |
|
} |
|
|
|
func FirstRemindInit(db *gorm.DB) { |
|
r := []Remind{ |
|
{ID: 1, Title: "Remind 1", DateTime: time.Now(), Content: "Remind 1 body"}, |
|
{ID: 2, Title: "Remind 2", DateTime: time.Now(), Content: "Remind 2 body"}, |
|
} |
|
result := db.Create(&r) |
|
if result.RowsAffected == 0 { |
|
panic("Not inserted test remind!") |
|
} |
|
}
|
|
|