-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.js
More file actions
67 lines (60 loc) · 3.09 KB
/
Copy pathseed.js
File metadata and controls
67 lines (60 loc) · 3.09 KB
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
63
64
65
66
var mongoose= require("mongoose");
var Campground= require("./models/campground");
var Comment= require("./models/comment");
var data= [
{
name: "Anjuna beach – Goa",
image: "https://cdn.pixabay.com/photo/2018/05/16/15/49/camper-3406137__480.jpg",
description: "Camping on a beach is truly something every traveler must experience. Anjuna Beach is one of the best camping sites in India. The popular beach in Goa has some of the best scenes and lifestyle of Goa’s hippy culture. Camping here means hearing the constant melody of waves, amazing access to sunrise and sunset. Beaches, chapels and flea markets are close by, so is the happening nightlife."
},
{
name: "Tso Moriri Lake, Ladakh",
image: "https://cdn.pixabay.com/photo/2017/06/17/03/17/gongga-snow-mountain-2411069__480.jpg",
description: "Tsomoriri Lake is the highest lake in the world and located in Ladakh. Camping here is the experience of a lifetime"
},
{
name: "Anjuna beach – Goa",
image: "https://cdn.pixabay.com/photo/2018/05/16/15/49/camper-3406137__480.jpg",
description: "Camping on a beach is truly something every traveler must experience. Anjuna Beach is one of the best camping sites in India. The popular beach in Goa has some of the best scenes and lifestyle of Goa’s hippy culture. Camping here means hearing the constant melody of waves, amazing access to sunrise and sunset. Beaches, chapels and flea markets are close by, so is the happening nightlife."
}
]
function seedDB(){
//delete all campgrounds
Campground.deleteMany({}, function(err){
if(err){
console.log(err);
}else{
Comment.deleteMany({}, function(err){
if(err){
console.log(err);
}else{
//add few campgrounds
data.forEach(function(seed){
Campground.create(seed, function(err, campground){
if(err){
console.log(err);
}else{
console.log("addaded campground");
//create comments
Comment.create(
{
text: "this place is great, but i wish there was internet",
author: "Mazumdar"
},function(err, comment){
if(err){
console.log(err);
}else{
campground.comments.push(comment);
campground.save();
console.log("created comments")
}
});
}
});
});
}
})
}
});
}
module.exports= seedDB;