Seeding the Database

In this section, we will fill our database with the necessary data for the application to function properly

Database seeding is the initial seeding of a database with data. Seeding a database is a process in which an initial set of data is provided to a database when it is being installed. It is especially useful when we want to populate the database with data we want to develop in future. This is often an automated process that is executed upon the initial setup of an application. The data can be dummy data or necessary data such as an initial administrator account.

Database seeding. (2020, July 10). Retrieved from https://en.wikipedia.org/wiki/Database_seeding

To seed the database, we will take advantage of a file called seed.js located at models/seed.js. Running this file creates all the roles and applications that are already implemented in SMU Portal. After executing npm run seed we should get the following output:

~/smuportal-backend (master)
$ npm run seed

> smuportal@0.0.0 seed ~/smuportal-backend
> node models/seed.js

Database connection established!
Roles seeded successfully
Apps seeded successfully
Seeding terminated... Database connection closed.
You can now safely run `npm start`

Last updated