-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
56 lines (53 loc) · 3.32 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
const mongoose = require("mongoose");
const Campground = require("./models/campground");
const Comment = require("./models/comment");
// seed Data
var data = [
{
name: "Cloud's Rest",
image: "https://images.unsplash.com/photo-1492648272180-61e45a8d98a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
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: "Queen Hill",
image: "https://images.unsplash.com/photo-1483381719261-6620dfa2d28a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
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: "Granite Hill",
image: "https://images.unsplash.com/photo-1501703979959-797917eb21c8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60",
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.deleteMany({}, function(err){
if(err){
console.log("ERROR in removing all campgrounds");
}
// console.log("Campgrounds Removed");
// //Creating seed data
// data.forEach(function(seed){
// Campground.create(seed, function(err, campground){
// if(err){
// console.log("ERROR in creating seed data");
// } else{
// console.log("Campground created");
// //creating comment
// Comment.create({
// author: "Homie",
// text: "This is a beautiful place, wish there is Internet too"
// }, function(err, comment){
// if(err){
// console.log("ERROR in creating comment");
// }else {
// campground.comments.push(comment);
// campground.save();
// console.log("Comment Added");
// }
// });
// }
// });
// });
});
}
module.exports = seedDB;