-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeds.js
56 lines (51 loc) · 2.63 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
var mongoose = require("mongoose");
var Campground = require("./models/campground");
var Comment = require("./models/comment");
var data = [
{
name: "Cloud Rest",
image: "https://farm4.staticflickr.com/3795/10131087094_c1c0a1c859.jpg",
description: "Do you see any Teletubbies in here? Do you see a slender plastic tag clipped to my shirt with my name printed on it? Do you see a little Asian child with a blank expression on his face sitting outside on a mechanical helicopter that shakes when you put quarters in it? No? Well, that's what you see at a toy store. And you must think you're in a toy store, because you're here shopping for an infant named Jeb."
},
{
name: "Desert Place",
image: "https://farm4.staticflickr.com/3859/15123592300_6eecab209b.jpg",
description: "Normally, both your asses would be dead as fucking fried chicken, but you happen to pull this shit while I'm in a transitional period so I don't wanna kill you, I wanna help you. But I can't give you this case, it don't belong to me. Besides, I've already been through too much shit this morning over this case to hand it over to your dumb ass."
},
{
name: "Can Canyon",
image: "https://farm1.staticflickr.com/189/493046463_841a18169e.jpg",
description: "Now that there is the Tec-9, a crappy spray gun from South Miami. This gun is advertised as the most popular gun in American crime. Do you believe that shit? It actually says that in the little book that comes with it: the most popular gun in American crime. Like they're actually proud of that shit. "
},
];
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 campground");
Comment.create(
{
text: "This place is great but lots of bears",
author: "Hamburgler"
}, function(err, comment){
if(err){
console.log(err);
} else {
campground.comments.push(comment);
campground.save();
console.log("Created new comment");
}
});
}
});
});
});
}
module.exports = seedDB;