Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Step 3.14: Added stub data to the collection in the server side
  • Loading branch information
dotansimha authored and DAB0mB committed Feb 26, 2017
1 parent 579d0f4 commit 4c6c76c
Showing 1 changed file with 60 additions and 1 deletion.
61 changes: 60 additions & 1 deletion api/server/main.ts
@@ -1,5 +1,64 @@
import * as moment from "moment";
import { Meteor } from 'meteor/meteor';
import { Chats, Messages } from "../collections/whatsapp-collections";

Meteor.startup(() => {
// code to run on server at startup
if (Chats.find({}).cursor.count() === 0) {
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()
});
}
});

0 comments on commit 4c6c76c

Please sign in to comment.