-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
70 lines (66 loc) · 3.09 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
63
64
65
66
67
68
69
70
var mongoose = require("mongoose"),
campground=require("./models/campground"),
comment=require("./models/comment");
var data= [
{
name:"BigSur Campground",
img: "http://www.yellowstonenationalparklodges.com/wp-content/gallery/madison-campground/madison-campground-9.jpg",
desc: "Big Sur Campground & Cabins offers camping and lodging with the emphasis on Family. Enjoy tent and RV camping on the forest floor as you watch the kids inner tube by in the cool water. Or pamper your family in one of several styles of cabins, from rustic camping cabins to fully equipped cabins with kitchens and fireplaces.",
author:{
id:"5977ed8f5ce5b02b419711bc",
username:"qing"
}
},
{
name:"Madsion Campground",
img:"http://www.yellowstonenationalparklodges.com/wp-content/gallery/madison-campground/madison-campground-11.jpg",
des:"There are over 270 individual sites and 3 group sites. The campground can accommodate RVs and tents. Campsites for hikers and cyclists are also available. Each site includes a picnic table and fire grate. Access to water is nearby the sites.",
author:{
id:"5977ed8f5ce5b02b419711bc",
username:"qing"
}
},
{
name:"Toyon Campground",
img:"http://www.yellowstonenationalparklodges.com/wp-content/gallery/madison-campground/madison-campground-3.jpg",
des:"By reservation only, this camping area accommodates 50 people and is open from the 2nd Sunday in May to the 3rd Sunday in October. Campfires require a permit. Site has 16 picnic tables, 7 BBQ's, water faucet and fountain, and has nearby restrooms.",
author:{
id:"5977ed8f5ce5b02b419711bc",
username:"qing"
}
},
{
name:"Del Valle Regional Park",
img:"http://www.yellowstonenationalparklodges.com/wp-content/gallery/madison-campground/madison-campground-17.jpg",
des:"Deep in a valley framed by oak-covered hills, with sailboats and sailboards skimming over its waters, Del Valle is like a lakeside resort only 10 miles south of Livermore.",
author:{
id:"5977ed8f5ce5b02b419711bc",
username:"qing"
}
}
]
function seedDB(){
campground.remove({},function(error){
if(error) console.log(error);
data.forEach(function(seed){
campground.create(seed,function(error,cp){
if(error) console.log(error);
else{
console.log("create a new camp");
// comment.create({
// text:"really great place",
// author: "qing"
// }, function(error,comment){
// if(error) console.log(error);
// else{
// cp.comments.push(comment);
// cp.save();
// console.log("new comment");
// }
// });
}
});
});
});
}
module.exports=seedDB;