1
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)

}

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 08 '22 at 00:05

1 Answers1

0

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.

m4N0Lo
  • 1
  • 1