-
Notifications
You must be signed in to change notification settings - Fork 33
/
bootstrap.js
60 lines (56 loc) · 1.57 KB
/
bootstrap.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
Meteor.startup(function () {
if (Chats.find().count() === 0) {
Messages.remove({});
var messages = [
{
text: 'You on your way?',
timestamp: moment().subtract(1, 'hours').toDate()
},
{
text: 'Hey, it\'s me',
timestamp: moment().subtract(2, 'hours').toDate()
},
{
text: 'I should buy a boat',
timestamp: moment().subtract(1, 'days').toDate()
},
{
text: 'Look at my mukluks!',
timestamp: moment().subtract(4, 'days').toDate()
},
{
text: 'This is wicked good ice cream.',
timestamp: moment().subtract(2, 'weeks').toDate()
}
];
messages.forEach(m => Messages.insert(m));
var chats = [
{
name: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg'
},
{
name: 'Bryan Wallace',
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg'
},
{
name: 'Avery Stewart',
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg'
},
{
name: 'Katie Peterson',
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg'
},
{
name: 'Ray Edwards',
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg'
}
];
chats.forEach( chat => {
let message = Messages.findOne({ chatId: { $exists: false } });
chat.lastMessage = message;
let chatId = Chats.insert(chat);
Messages.update(message._id, { $set: { chatId: chatId } })
});
}
});