Creating a Seed Route
#
Lesson Objectives- Create a Seed Route
#
Create a Seed RouteSometimes you might need to add data to your database for testing purposes. You can do so like this:
app.get("/fruits/seed", (req, res) => { Fruit.create( [ { name: "grapefruit", color: "pink", readyToEat: true, }, { name: "grape", color: "purple", readyToEat: false, }, { name: "avocado", color: "green", readyToEat: true, }, ], (err, data) => { res.redirect("/fruits"); } );});