-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
executable file
·62 lines (60 loc) · 3.24 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var mongoose = require("mongoose");
var Campground = require("./models/campground");
var Comment = require("./models/comment");
var data = [
{
name: "cloud's rest",
image:
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRcx8VI-yrfGlqL1cmLAlI6YgpwCccWnipbXg&usqp=CAU",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
},
{
name: "Lawrence of Arabia",
image:
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSkAX_JQyT6MoFFQ6LMcTrdfQWu0fp4xXV3zg&usqp=CAU",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
},
{
name: "Oceania",
image:
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQkCf5x17t1tdc_zBBewXK2LmpscjRQFYGK6A&usqp=CAU ",
description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
},
];
function seedDB() {
Campground.remove({}, function (err) {
if (err) {
console.log(err);
}
console.log("Removed Campgrounds");
data.forEach(function (seed) {
Campground.create(seed, function (err, campground) {
if (err) {
console.log(err);
} else {
console.log("Added a Campground");
Comment.create(
{
text:
"Great place but kinda creepy. Has demonic vibrations.",
author: "Kapren Johnson",
},
function (err, comment) {
if (err) {
console.log(err);
} else {
campground.comments.push(comment);
campground.save();
console.log("Created new comment");
}
}
);
}
});
});
});
}
module.exports = seedDB;