Save method
This commit is contained in:
22
app/main.go
22
app/main.go
@ -121,6 +121,25 @@ func doGet(db *gorm.DB) {
|
||||
fmt.Printf(">> %+v %s (alive %t)\n", cert.Id, cert.CreatedAt, cert.Alive)
|
||||
}
|
||||
|
||||
func doSave(db *gorm.DB) {
|
||||
repo := repository.RepoBase[models.Company]{}
|
||||
repo.Init(db, nil)
|
||||
|
||||
company := models.Company{
|
||||
Name: "Test company",
|
||||
Address: "Some address",
|
||||
City: "Some city",
|
||||
Email: "email@example.org",
|
||||
Oib: "123456",
|
||||
}
|
||||
|
||||
_, err := repo.Save(&company)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("New company id: %s\n", company.Id.String())
|
||||
}
|
||||
|
||||
func doExists(db *gorm.DB) {
|
||||
repo := repository.RepoBase[models.Cert]{}
|
||||
repo.Init(db, nil)
|
||||
@ -147,7 +166,8 @@ func main() {
|
||||
|
||||
// doMagic(db)
|
||||
// doList(db)
|
||||
doCount(db)
|
||||
// doCount(db)
|
||||
doSave(db)
|
||||
// doGet(db)
|
||||
// doExists(db)
|
||||
// inheritance.DoInheritanceTest()
|
||||
|
||||
Reference in New Issue
Block a user