Advertisement
nadeemjq

SyntheticMutation

Mar 4th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Declare publication
  2.  
  3. Meteor.publish('messages_by_thread', function (questionId) {
  4.   check(questionId, String);
  5.  
  6.     // perform additional security checks here
  7.   const channel = 'HZSos4nBiJfQRKgeA';
  8.   console.log(channel);
  9.   return Questions.find({ _id: 'HZSos4nBiJfQRKgeA' });
  10. });
  11.  
  12. // Subscribe
  13.  
  14. Template.schedulesFooter.onCreated(() => {
  15.   const self = Template.instance();
  16.  
  17.   self.autorun(() => {
  18.     self.subscribe('messages_by_thread', 'HZSos4nBiJfQRKgeA');
  19.  
  20.     return undefined;
  21.   });
  22. });
  23.  
  24. // Declare method (server-side only)
  25.  
  26. Meteor.methods({
  27.   'questions.typing': function (questionId) {
  28.     check(questionId, String);
  29.  
  30.     const random = () => Random.id();
  31.     SyntheticMutator.update(Questions, 'HZSos4nBiJfQRKgeA', {
  32.       $set: { // you can use any modifier supported by minimongo
  33.         random: random(),
  34.       },
  35.     });
  36.   },
  37. })
  38.  
  39. // Call method
  40. Meteor.call('questions.typing', 'HZSos4nBiJfQRKgeA');
  41.  
  42.  
  43. /**
  44.  * No errors in console or anywhere.
  45.  * But I can't see the random field anywhere in my minimongo.
  46. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement