forked from gerickson808/fireframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
161 lines (156 loc) · 4.82 KB
/
seed.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
var mongoose = require('mongoose');
var Promise = require('bluebird');
var chalk = require('chalk');
var connectToDb = require('./server/db');
var User = mongoose.model('User');
var Team = mongoose.model('Team');
var Project = mongoose.model('Project');
var Wireframe = mongoose.model('Wireframe');
var allUsers, allTeams;
connectToDb.then(function () {
mongoose.connection.db.dropDatabase();
}).then(function() {
chalk.green('Dropped DB before seeding');
// console.log("LOOK HERE");
return User.create([
{
firstName: 'Gus',
lastName: 'Fring',
email: 'testing@fsa.com',
password: 'password'
},
{
firstName: 'Jeremy',
lastName: 'Obama',
email: 'obama@gmail.com',
password: 'potus',
admin: true
},
{
firstName: 'Donald',
lastName: 'Drumpf',
email: 'test@gmail.com',
password: '1'
},
{
firstName: 'Ted',
lastName: 'Rubio',
email: 'user1@gmail.com',
password: '1'
}
]);
}).then(function(users) {
allUsers = users;
// console.log('users: ', users);
return Team.create([
{
name: "Team Rebar",
administrator: users[0],
members: [users[1], users[2]]
},
{
name: "Team Concrete",
administrator: users[1],
members: [users[1], users[3]]
}
]);
}).then(function(teams) {
allTeams = teams;
// console.log('-------------')
// console.log('teams: ', teams)
return Wireframe.create([
{
master: true,
components: [
{
type: "box",
style: {
"background-color": "rgb(255, 255, 255)",
"border-color": "rgb(128, 128, 128)",
"border-style": "solid",
height: "50px",
left: 170,
opacity: "1",
top: 145.98959350585938,
width: "50px",
"z-index": "0"
}
},
{
type: "circle",
style: {
"background-color": "rgb(255, 255, 255)",
"border-color": "rgb(128, 128, 128)",
"border-style": "solid",
height: "327px",
left: 175.98959350585938,
opacity: "1",
top: 293.9930725097656,
width: "309px",
"z-index": "0"
}
}
],
photoUrl: 'http://blog.skipper18.com/wp-content/uploads/2014/01/wireframe-example-large-1.png'
},
{
master: true,
components: [
{
type: "box",
style: {
"background-color": "rgb(255, 255, 255)",
"border-color": "rgb(128, 128, 128)",
"border-style": "dashed",
height: "50px",
left: 170,
opacity: "1",
top: 145.98959350585938,
width: "30px",
"z-index": "0"
}
},
{
type: "circle",
style: {
"background-color": "rgb(255, 255, 255)",
"border-color": "rgb(128, 128, 128)",
"border-style": "dashed",
height: "327px",
left: 180,
opacity: "1",
top: 293.9930725097656,
width: "200px",
"z-index": "0"
}
}
],
photoUrl: 'http://wireframesketcher.com/samples/YouTube.png'
}
]);
}).then(function(wireframes) {
// console.log('-------------')
// console.log('wireframes: ', wireframes)
return Project.create([
{
name: "Fullstack Website",
team: allTeams[0],
creator: allUsers[0],
wireframes: [wireframes[0]],
type: "Website"
},
{
name: "Jimmy's Newsletter",
team: allTeams[1],
creator: allUsers[1],
wireframes: [wireframes[1]],
type: "Newsletter"
}
]);
}).then(function(){
chalk.green('Seed successful!');
process.kill(0);
}).catch(function (err) {
console.log(err);
process.kill(1);
});