Describe the feature
I am proposing that Gorm has a built in Seeding method so that developers can quickly seed databases within gorm without having to re-create the functionality.
Example Proposed Usage:
// make class (or interface) that is the same shape as your database
type person struct {
name string
age int
}
// create an array of 'dummy' data using the object
seedArray := [3]person{
{
name: "John Doe",
age: 18
},
{
name: "Jane Doe",
age: 22
},
{
name: "Steve Doe",
age: 32
}
}
// pass the array into a seeding method
DB.Seed(seedSlice)
Motivation
Seeding is a required process during the development process, and during platform migrations. Creating a seeding method will improve the developer's quality of life, and could increase the user-ship of GORM and GoLang as a whole.
Related Issues
Developers have asked if the functionality exists.
Some Developers have written Work around Tutorials
Comment From: Chaostheorie
This sounds like functionality that should be done in a separate library and not as part of an ORM. Maybe an integration of the existing projects for seeding, like jaswdr/faker, with gorm, similar to datatypes, might be a better fit instead.
Comment From: github-actions[bot]
This issue has been automatically marked as stale because it has been open 360 days with no activity. Remove stale label or comment or this will be closed in 180 days
Comment From: saeidee
Seeding seems to not be the responsibility of ORM, however, feel free to implement it as a plugin. https://gorm.io/docs/write_plugins.html