Search⌘ K
AI Features

First Model: Note Model

Explore how to build the Note model that represents your notes table and understand database migrations with Beego's bee tool. Learn to create, apply, and rollback migrations effectively, enabling structured data management in your Golang web application.

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: Beego provides a feature via the bee command line to create database migrations. These migrations are part of the code. The bee ...