forked from somnolentsoylent/somnolentsoylent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestData.js
More file actions
130 lines (123 loc) · 3.59 KB
/
testData.js
File metadata and controls
130 lines (123 loc) · 3.59 KB
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
// testData.js
var mongoose = require('mongoose');
var User = require('./server/schemas/userSchema');
var Event = require('./server/schemas/eventsSchema');
var eventModels = require('./server/models/eventModels');
var friendModels = require('./server/models/friendModels');
mongoose.Promise = require('bluebird');
if (!process.env.MONGODB_URI) {
mongoose.connect('mongodb://localhost/sembly');
}
//DATA
var users = [
{
firstName: 'Spenjamin',
lastName: 'Franklin',
email: 'spencer@test.com',
password: 'test',
photoUrl: 'http://www.cutestpaw.com/wp-content/uploads/2015/04/Doug-the-Pug.png'
},
{
firstName: 'Omar',
lastName: 'Mohamed',
email: 'omar@test.com',
password: 'test',
photoUrl: 'https://avatars0.githubusercontent.com/u/16041716?v=3&s=400'
},
{
firstName: 'Carl',
lastName: 'Flores',
email: 'carlos@test.com',
password: 'test',
photoUrl: 'https://avatars0.githubusercontent.com/u/18621668?v=3&s=400'
},
{
firstName: 'Kanye',
lastName: 'West',
email: 'god@god.com',
password: 'test',
photoUrl: 'http://thesource.com/wp-content/uploads/2016/08/kanye-west2.jpg'
}
];
var userIds = [];
var events = [
{
name:'Basketball',
location: [-122.4066, 37.7786],
tags:['sports','basketball'],
image: 'https://upload.wikimedia.org/wikipedia/commons/7/7a/Basketball.png'
},
{
name:'Happy Hour',
location: [-122.3980, 37.7794],
tags:['drinks', 'entertainment'],
image: 'http://images.r.cruisecritic.com/features/2016/06/bottoms-up-hero.jpg'
},
{
name:'Street Dancing',
location: [-122.4075, 37.7878],
tags:['dancing', 'entertainment'],
image: 'http://thedancecompanysaltlakecity.com/wp-content/uploads/2015/05/boys_street_dance_pp.png'
},
{
name:'Yodel Off',
location: [-122.4120, 37.7918],
tags:['music', 'singing'],
image: 'http://pad2.whstatic.com/images/thumb/a/a4/Yodel-Step-5.jpg/aid12588-728px-Yodel-Step-5.jpg'
},
{
name:'Birthday Party',
location: [-122.4020, 37.7877],
tags:['party', 'entertainment'],
image: 'https://media.giphy.com/media/xT0BKqhdlKCxCNsVTq/giphy.gif'
},
{
name:'Concert',
location: [-122.4101, 37.7825],
tags:['concert', 'music'],
image: 'http://www.ticketswest.com/media/1028/concert_Featured%20Event%20Tile.jpg'
}
];
mongoose.connection.on('connected', () => {
//Populate Database
User.remove({}).exec()
.then(() => {
return Event.remove({}).exec();
})
.then(()=> {
users = users.map(user => new User(user));
return User.create(users);
})
.then(users => {
console.log('Test User id = ', users[0]._id);
users.forEach(user => {
userIds.push(user._id);
});
events[0].invitedUsers = userIds;
events[1].invitedUsers = userIds;
events[4].invitedUsers = userIds;
return Promise.all(events.map(event => eventModels.addEvent(event)));
})
.then(events => {
return Event.findOne({'name': 'Basketball'})
})
.then(event => {
return eventModels.saveEvent(event._id, users[0]._id)
})
.then(success => {
return Promise.all([friendModels.addFriend(users[0]._id, users[2]._id), friendModels.addFriend(users[1]._id, users[0]._id), friendModels.addFriend(users[0]._id, users[3]._id)])
})
.then(success => {
return Promise.all([friendModels.acceptFriend(users[2]._id, users[0]._id), friendModels.acceptFriend(users[3]._id, users[0]._id)])
})
.then(success => {
console.log('Database populated');
if (!process.env.MONGODB_URI) {
process.exit();
}
})
.catch(error => {
console.log(error);
process.exit(1);
});
});