Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. import { Mongo } from 'meteor/mongo';
  2.  
  3. Questions = new Mongo.Collection("Questions");
  4.  
  5. import '../imports/api/database.js';
  6.  
  7. FlowRouter.route('/', {
  8. action: function() {
  9. BlazeLayout.render('MainPage');
  10.  
  11. console.log(Questions.find({}).count());
  12.  
  13. if(Meteor.isClient) {
  14. Template.register.events({
  15. 'submit form'(event, template) {
  16. event.preventDefault();
  17.  
  18. const EmailConst = template.find('#email').value;
  19. const UsernameCost = template.find('#username').value;
  20. const PasswordConst = template.find('#password').value;
  21.  
  22. Accounts.createUser({
  23. username: UsernameCost,
  24. email: EmailConst,
  25. password: PasswordConst
  26. });
  27. }
  28. });
  29.  
  30. Template.login.events({
  31. 'submit form'(event, template) {
  32. event.preventDefault();
  33.  
  34. const UsernameCost = template.find('#login-username').value;
  35. const PasswordConst = template.find('#login-password').value;
  36.  
  37. Meteor.loginWithPassword(UsernameCost, PasswordConst);
  38. }
  39. });
  40.  
  41. Template.logout.events({
  42. 'click #LogoutUser'(event) {
  43. event.preventDefault();
  44. Meteor.logout();
  45. }
  46. })
  47. };
  48.  
  49. Template.createquestion.events({
  50. 'submit form'(event, template) {
  51. event.preventDefault();
  52.  
  53. const QuestionNewSub = template.find('#question-subject').value;
  54. const QuestionBody = template.find('#question-area').value;
  55. const QuestionId = Math.floor((Math.random() * 9999999999) + 1);
  56. const QuestionUsername = Meteor.user().username;
  57. const QuestionNewActive = true;
  58. const creationDate = new Date();
  59.  
  60. Questions.insert({
  61. id: QuestionId,
  62. poster: QuestionUsername,
  63. subject: QuestionNewSub,
  64. content: QuestionBody,
  65. active: QuestionNewActive,
  66. createdAt: creationDate
  67. });
  68.  
  69. console.log("Question posted!");
  70.  
  71. }
  72. })
  73.  
  74. Template.getquestions.helpers({
  75.  
  76. results() {
  77. Questions.find({
  78. active: true
  79. }).count();
  80. },
  81.  
  82. });
  83.  
  84. }
  85. });
  86.  
  87. FlowRouter.route('/social', {
  88. action: function() {
  89. console.log("Yeah! We are on the social route!");
  90. }
  91. });
  92.  
  93. import { Meteor } from 'meteor/meteor';
  94.  
  95. Meteor.onConnection(function() {
  96. import '../imports/api/database.js';
  97. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement