var (
err  error
User []AcctDetails

)

type ( AcctDetails struct { gorm.Model ID uint AcctName string gorm:"default:John Doe" AcctNumber string UsersPhoneNo string } )

func CreateDb(c fiber.Ctx) error { db := database.DB

c.BodyParser(new(User))
// user := User

db.Create(&User{ID: AcctDetails.ID, AcctName: AcctDetails.AcctName, AcctNumber: AcctDetails.AcctNumber, UsersPhoneNo: AcctDetails.UsersPhoneNo})
return c.JSON(User)

}

1

There are 1 best solutions below

0
On

You can try to use db.AutoMigrate(&AcctDetails{}). This will create your table at the db. db.Create will create a record and assign a value to the fields specified.