Skip to content

Commit

Permalink
Step 6.11: Replace chats fabrication with users fabrication
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and DAB0mB committed Feb 26, 2017
1 parent 1f8494a commit 48cc20f
Showing 1 changed file with 36 additions and 58 deletions.
94 changes: 36 additions & 58 deletions server/imports/server-main/main.ts
@@ -1,66 +1,44 @@
import {Chats} from "../../../both/collections/chats.collection";
import {Messages} from "../../../both/collections/messages.collection";
import * as moment from "moment";
import {Users} from '../../../both/collections/users.collection';
import {Accounts} from 'meteor/accounts-base';

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()
if (Users.collection.find().count()) return;

[{
phone: '+972540000001',
profile: {
name: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg'
}
}, {
phone: '+972540000002',
profile: {
name: 'Bryan Wallace',
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg'
}
}, {
phone: '+972540000003',
profile: {
name: 'Avery Stewart',
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg'
}
}, {
phone: '+972540000004',
profile: {
name: 'Katie Peterson',
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg'
}
}, {
phone: '+972540000005',
profile: {
name: 'Ray Edwards',
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg'
}
}].forEach(user => {
Accounts.createUserWithPhone(user);
});
}
}

0 comments on commit 48cc20f

Please sign in to comment.