Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Populating the Database with Initial Data | Deploying a Next.js App and Setting Up a Database
Next.js 14 Mastery for Building Modern Web Apps
course content

Conteúdo do Curso

Next.js 14 Mastery for Building Modern Web Apps

Next.js 14 Mastery for Building Modern Web Apps

1. Introduction to Next.js
2. Setting Up a Next.js Project
3. Building Pages and Layouts in Next.js
4. Deploying a Next.js App and Setting Up a Database
5. Fetching and Displaying Data in Next.js
6. Advanced Next.js Features and Optimizations
7. Implementing Authentication in Next.js

book
Populating the Database with Initial Data

Let's add some initial data to the database.

Look for the file named seed.js in the scripts folder of the project. This script contains instructions for creating and seeding tables for invoices, sellers, users, and income.

Don't worry if you don't fully understand the code details. In essence, the script uses SQL to create the tables and populates them with data from the placeholder-data.js file.

To proceed, add the following line to your scripts in the package.json file:

To proceed, we need to access the terminal and execute the following command: npm run seed.

We should see the following messages in the terminal, indicating that the data was successfully populated.

Database Testing

Navigate to the "Query" tab to execute the SQL request. Let's attempt to run the following query.

We should get the following result:

In Practice

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 4. Capítulo 4
We're sorry to hear that something went wrong. What happened?
some-alt