-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeds.js
139 lines (109 loc) · 3.17 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Created by Chris on 1/7/2018.
*/
var mongoose = require("mongoose");
var Subject = require("./models/subject")
var Review = require("./models/review")
var Course = require("./models/course")
var Comment = require("./models/comment")
var User = require("./models/user")
var subjects = [
{
name: "web",
image: "https://i.imgur.com/nosrsBg.jpg", //https://imgur.com/nosrsBg
quote: "\"Websites promote you 24/7: No employee will do that.\"",
author: "- Paul Cookson"
},
{
name: "python",
image: "https://i.imgur.com/mvNWVNW.jpg", //https://imgur.com/a/Q1k33
quote: "\"Python has been an important part of Google since the beginning.\"",
author: "-Peter Norvig"
},
{
name: "java",
image: "https://i.imgur.com/QZP7KY8.jpg", //https://imgur.com/a/rMtbT
quote: "\"Java is C++ without the guns, knives, and clubs.\"",
author: "-James Gosling"
},
{
name: "data science",
image: "https://i.imgur.com/zzrKnK7.jpg", //https://imgur.com/a/Goeej
quote: "\"Data is the new science. Big data holds the answers.\"",
author: "- Pat Gelsinger"
},
{
name: "operating system",
image: "https://i.imgur.com/mAkbjU5.jpg", //https://imgur.com/a/ygIVm
quote: "\"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.\"",
author: "- Dennis Ritchie"
}
]
var reviews = [
{
title: "This is a review1",
author: "Author1",
paper: "PaperTitle1",
content: "LALABLABLA"
},
{
title: "This is a review2",
author: "Author2",
paper: "PaperTitle2",
content: "YOOOOOOOO!!!!!"
}
]
function seedDB() {
User.remove({},function (err) {
if(err){
console.log(err);
}
console.log("Removed all users")
})
Comment.remove({},function (err) {
if(err){
console.log(err);
}
console.log("Removed all comments")
})
//Remove all Subjects
Course.remove({},function(err){
if(err){
console.log(err);
}
console.log("Removed all courses")
});
Review.remove({},function(err){
if (err) {
console.log(err)
}
console.log("Removed all reviews")
//Adds subject
reviews.forEach(function (subject) {
Review.create(subject, function (err, subject) {
if (err) {
console.log(err);
} else {
console.log("Added a subject");
}
})
})
})
Subject.remove({}, function (err) {
if (err) {
console.log(err)
}
console.log("Removed all subjects")
//Adds subject
subjects.forEach(function (subject) {
Subject.create(subject, function (err, subject) {
if (err) {
console.log(err);
} else {
console.log("Added a subject");
}
})
})
}
)}
module.exports = seedDB;