In Gorm, the _______ function is used to create a new record in the database.

  • Create
  • Insert
  • New
  • Save
In Gorm, the New function is used to create a new record in the database. This function initializes a new instance of the corresponding model struct without adding it to the database. It's useful when you want to create a new record and populate its fields before saving it to the database. This approach provides more control over the creation process, allowing you to set default values or perform validations before persisting the data. Using New followed by Save or Create allows you to manage the creation and persistence of database records efficiently.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *