-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeds.js
53 lines (51 loc) · 2.07 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
var mongoose = require('mongoose');
var Friend = require('./models/friends');
var Comment = require('./models/comments');
var data = [
{
name: "First Post",
image: "https://images.pexels.com/photos/336413/pexels-photo-336413.jpeg?h=350&auto=compress&cs=tinysrgb",
text: "Create professional resumes, CV and bio-data online for free, in minutes. Simply fill in your details and generate beautiful PDF and HTML resumes!"
// created: {type: Date, default: Date.now}
},
{
name: "Welcome to Paris",
image: "https://images.pexels.com/photos/338515/pexels-photo-338515.jpeg?h=350&auto=compress&cs=tinysrgb",
text: "A simple method using valid CSS to keep your footer at the bottom of the screen on pages with little content."
},
{
name: "Here comes the Mustang!",
image: "https://images.pexels.com/photos/340779/pexels-photo-340779.jpeg?h=350&auto=compress&cs=tinysrgb",
text: "lectroshot - Capture website screenshots with optional device and network emulation as jpg, png or pdf (with web fonts!) using Electron / Chrome"
}
];
function seedDB() {
Friend.remove({}, function(err) {
if(err) {
console.log(err);
}
console.log("Cleaned up the database!");
data.forEach(function(seed) {
Friend.create(seed, function(err, friend) {
if(err) {
console.log(err);
} else {
console.log("New Friend added!");
Comment.create({
author: "Vishal",
text: "Lorem ipsum lore ti si ipsum"
}, function(err, comment) {
if(err) {
console.log(err);
} else {
console.log("New Comment!");
friend.comments.push(comment);
friend.save();
}
});
}
});
});
});
}
module.exports = seedDB;