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!") } }