-
Notifications
You must be signed in to change notification settings - Fork 8
/
seeds.js
38 lines (32 loc) · 1.86 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
var mongoose=require("mongoose");
var campground=require("./modules/campgrounds");
var comment=require("./modules/comments")
var data=[
{title:"Desert mela",image:"https://farm3.staticflickr.com/2630/4089140779_fc5cd0c694.jpg",description:"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad quod culpa voluptatibus expedita, consectetur, deleniti eum saepe asperiores eius eaque minus! Rerum, odio ullam delectus magni. Corrupti, unde. Consequuntur, ipsum?"},
{title:"Car mela",image:"https://farm7.staticflickr.com/6014/6015893151_044a2af184.jpg",description:"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad quod culpa voluptatibus expedita, consectetur, deleniti eum saepe asperiores eius eaque minus! Rerum, odio ullam delectus magni. Corrupti, unde. Consequuntur, ipsum?"},
{title:"Lot mela",image:"https://farm1.staticflickr.com/104/274197688_974a87740e.jpg",description:"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad quod culpa voluptatibus expedita, consectetur, deleniti eum saepe asperiores eius eaque minus! Rerum, odio ullam delectus magni. Corrupti, unde. Consequuntur, ipsum?"}
]
function seedDB(){
campground.remove({},function(err){
if(err)
console.log(err);
else
{
console.log("delete successful");
data.forEach(function(seed){
campground.create(seed,function(err,seed){
console.log("seed added");
comment.create(
{text:"This a boring bad place dont come here",
author:"sennu"
},function(err,comment){
seed.comments.push(comment);
seed.save();
console.log("comment added");
})
})
})
}
})
}
module.exports=seedDB;