Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Meteor.methods({
  2. 'pushInfo': function(){
  3. if (this.userId) {
  4. userManagement.update({
  5. '_id': this.userId
  6. }, {
  7. $push: {
  8. 'activeInfos': ["The Info/Object I want to push from another collection"]
  9. }
  10. }
  11. );
  12. }
  13. }
  14. });
  15.  
  16. Template.available.events({
  17. "click. push": function(e) {
  18. e.preventDefault();
  19. Meteor.call('pushInfo');
  20. }
  21. });
  22.  
  23. Template.available.events({
  24. "click .push": function(e) {
  25. e.preventDefault();
  26. var InfoId = this.InfoId;
  27. Meteor.call('pushInfo', InfoId);
  28. }, });
  29.  
  30. Meteor.methods({
  31. 'pushInfo': function(InfoId) {
  32. if (this.userId) {
  33. userManagement.update({
  34. '_id': this.userId
  35. }, {
  36. $push: {
  37. 'activeInfos': infoId
  38. }
  39. }
  40. );
  41. }
  42. }
  43. });
  44.  
  45. Template.available.events({
  46. "click. push"(e) {
  47. e.preventDefault();
  48. Meteor.call('pushInfo',this.InfoId);
  49. }
  50. });
  51.  
  52.  
  53. Meteor.methods({
  54. 'pushInfo'(infoId)=>{
  55. const info = Infos.findOne(infoId)
  56. if (this.userId && info) {
  57. userManagement.update(this.userId, { $push: { activeInfos: info }});
  58. }
  59. }
  60. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement