seed

package
v0.0.0-...-c0306e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TeamSeeder = &Seed{
	Name: "Team Seeder",
	Run: func(db *gorm.DB) {
		faker := faker.New()

		for i := 0; i < 3; i++ {
			err := db.Create(&model.Team{
				Name:        faker.Company().Name(),
				Description: faker.Lorem().Text(20),
			}).Error
			if err != nil {
				log.Error(err)
			}
		}
	},
}
View Source
var TeamUserSeeder = &Seed{
	Name: "Team User Relation Seeder",
	Run: func(db *gorm.DB) {
		for i := 0; i < 10; i++ {
			if err := db.Model(database.RandomTeam(db)).Association("Users").Append(database.RandomUser(db)); err != nil {
				log.Error(err)
			}
		}
	},
}
View Source
var UserSeeder = &Seed{
	Name: "User Seeder",
	Run: func(db *gorm.DB) {
		faker := faker.New()

		for i := 0; i < 5; i++ {
			err := db.Create(&model.User{
				FirstName: faker.Person().FirstName(),
				LastName:  faker.Person().LastName(),
				Email:     faker.Internet().Email(),
				Role:      model.RoleAdmin,
			}).Error
			if err != nil {
				log.Error(err)
			}
		}
	},
}

Functions

This section is empty.

Types

type Seed

type Seed struct {
	Name string
	Run  func(*gorm.DB)
}

type Seeder

type Seeder struct {
}

func (*Seeder) Execute

func (s *Seeder) Execute(db *gorm.DB)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL