feat: complete day 8
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
const db = require("./models/index");
|
||||
|
||||
async function seed() {
|
||||
await db.sequelize.sync({ force: true });
|
||||
|
||||
const quiz = await db.quiz.create({
|
||||
title: "JavaScript Basics",
|
||||
description: "A quiz on JavaScript fundamentals.",
|
||||
});
|
||||
|
||||
await db.question.bulkCreate([
|
||||
{
|
||||
quizId: quiz.id,
|
||||
questionText: 'What is the output of 1 + "2" in JavaScript?',
|
||||
options: JSON.stringify(["3", "12", "NaN", "Error"]),
|
||||
answer: "12",
|
||||
},
|
||||
{
|
||||
quizId: quiz.id,
|
||||
questionText: "Which company developed JavaScript?",
|
||||
options: JSON.stringify(["Netscape", "Microsoft", "Google", "Apple"]),
|
||||
answer: "Netscape",
|
||||
},
|
||||
{
|
||||
quizId: quiz.id,
|
||||
questionText: "What keyword declares a variable in JavaScript?",
|
||||
options: JSON.stringify(["var", "let", "const", "All of the above"]),
|
||||
answer: "All of the above",
|
||||
},
|
||||
]);
|
||||
|
||||
console.log("Database seeded!");
|
||||
process.exit();
|
||||
}
|
||||
|
||||
seed().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user