-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
45 lines (41 loc) · 837 Bytes
/
seeds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var mongoose = require("mongoose");
var Round = require("./models/round");
var Comment = require("./models/comment");
var seeds = [
{
score: 75,
fairways: 10,
greens: 9,
putts: 29
},
{
score: 80,
fairways: 7,
greens: 8,
putts: 32
},
{
score: 91,
fairways: 4,
greens: 5,
putts: 36
}
];
async function seedDB() {
await Round.remove({});
console.log("rounds removed");
await Comment.remove({});
console.log("comments removed");
for (const seed of seeds) {
let round = await Round.create(seed);
console.log("rounds created");
let comment = await Comment.create({
text: "A great round today for you",
author: "Timmmy"
});
console.log("comment created");
round.comment.push(comment);
round.save();
}
}
module.exports = seedDB;