Save method

This commit is contained in:
Eden Kirin
2024-06-26 01:55:33 +02:00
parent 3dc8d0d79f
commit bdc978aec1
6 changed files with 126 additions and 18 deletions

View File

@ -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()