javascriptmongodbmeteormeteor-collections

My meteor insert not working on with click event, but there is no error for me to debug


I have a click event that allows a user to insert data, or an object from one collection to another collection, the image bellow is the single object the user is capturing and inserting into the other collection.

enter image description here

This is the click event.

Template.postsView.events({
  'click .rediscover-toggle': function(e){
          var descovery = this;
          console.log(descovery);
          e.preventDefault();
          Meteor.call('rediscovering', {descovery: descovery});
      },
});

Everything here seems fine because that image is the console.log for the captured data, so when i click, i get that object in the console,

In my methods it looks like this

Meteor.methods({
  rediscovering: function (descovery) {
    RediscoveryCollection.insert(descovery);
  }
})

So im trying to insert that object as it is into another collection but its not inserting and i'm not getting any errors in the chrome browser nor the server terminal


Solution

  • The most common cause of this problem is that you are not publishing and subscribing to the collection. The object ends up getting inserted - you can verify that using the $ meteor mongo console. Please make sure that you have the autopublish package installed or that you do:

    server:

    Meteor.publish('rdc',()={
      return RediscoveryCollection.find();
    });
    

    client:

    Meteor.subscribe('rdc');