...

/

First Model: Note Model

First Model: Note Model

Learn the significance of a model to interact with the database. Also, learn to create and run database migrations.

Significance of models

In the notes application (or any web application), a critical component is the model, which defines the structure of the database table used to store notes. A model serves as a blueprint, specifying the attributes and properties of each entry within the table. By creating a model for the notes table, we establish a structured framework for organizing and managing data efficiently.

Database migrations

Let’s understand how database migrations can be handled in the Beego framework. To keep track of migrations, there are two ways used by developers:

  1. SQL commands: Developers track all the SQL commands they run to create, delete, or alter tables in the database. The primary disadvantage of this approach is that it is not easy to keep track of changes in different environments.

  2. Bee migrations: ...