github.com/lenfree/buffalo@v0.7.3-0.20170207163156-891616ea4064/examples/html-crud/grifts/db.go (about) 1 package grifts 2 3 import ( 4 "github.com/gobuffalo/buffalo/examples/html-crud/models" 5 "github.com/markbates/grift/grift" 6 "github.com/markbates/pop" 7 ) 8 9 var _ = grift.Add("db:seed", func(c *grift.Context) error { 10 return models.DB.Transaction(func(tx *pop.Connection) error { 11 users := models.Users{ 12 {FirstName: "Mark", LastName: "Bates", Email: "mark@example.com"}, 13 {FirstName: "Jane", LastName: "Doe", Email: "jane@example.com"}, 14 } 15 for _, u := range users { 16 err := tx.Create(&u) 17 if err != nil { 18 return err 19 } 20 } 21 return nil 22 }) 23 })