Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 3.3: Added the stub data to the server
- Loading branch information
1 parent
59ae997
commit 7e75490
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,66 @@ | ||
import {Chats} from "../../../both/collections/chats.collection"; | ||
import {Messages} from "../../../both/collections/messages.collection"; | ||
import * as moment from "moment"; | ||
|
||
export class Main { | ||
start(): void { | ||
if (Chats.collection.find().count()) return; | ||
|
||
let chatId; | ||
|
||
chatId = Chats.collection.insert({ | ||
title: 'Ethan Gonzalez', | ||
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg' | ||
}); | ||
|
||
Messages.collection.insert({ | ||
chatId: chatId, | ||
content: 'You on your way?', | ||
createdAt: moment().subtract(1, 'hours').toDate() | ||
}); | ||
|
||
chatId = Chats.collection.insert({ | ||
title: 'Bryan Wallace', | ||
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg' | ||
}); | ||
|
||
Messages.collection.insert({ | ||
chatId: chatId, | ||
content: 'Hey, it\'s me', | ||
createdAt: moment().subtract(2, 'hours').toDate() | ||
}); | ||
|
||
chatId = Chats.collection.insert({ | ||
title: 'Avery Stewart', | ||
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg' | ||
}); | ||
|
||
Messages.collection.insert({ | ||
chatId: chatId, | ||
content: 'I should buy a boat', | ||
createdAt: moment().subtract(1, 'days').toDate() | ||
}); | ||
|
||
chatId = Chats.collection.insert({ | ||
title: 'Katie Peterson', | ||
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg' | ||
}); | ||
|
||
Messages.collection.insert({ | ||
chatId: chatId, | ||
content: 'Look at my mukluks!', | ||
createdAt: moment().subtract(4, 'days').toDate() | ||
}); | ||
|
||
chatId = Chats.collection.insert({ | ||
title: 'Ray Edwards', | ||
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg' | ||
}); | ||
|
||
Messages.collection.insert({ | ||
chatId: chatId, | ||
content: 'This is wicked good ice cream.', | ||
createdAt: moment().subtract(2, 'weeks').toDate() | ||
}); | ||
} | ||
} |