Hi,
I’m very new to Meteor and I am having trouble inserting data to my collection after removing the autopublish and insecure packages. I have a simple schema in lib/collections/Weights.js:
Weights = new Mongo.Collection("Weights"); Weights.attachSchema(new SimpleSchema({ weight: { type: Number, label: "Weight (lbs)", optional: false } }));
I have the following template in client/mainTabs.html:
<template name="mainTabs"> {{#basicTabs name="" tabs=tabs}} {{#tabContent slug="weights"}} <h2>Log Weight</h2> {{> quickForm collection="Weights" template="bootstrap3-horizontal" label-class="col-sm-2" input-col-class="col-sm-10" id="InsertWeight" type="method" meteormethod="addWeight" resetOnSuccess=true}} {{/tabContent}} {{/basicTabs}} </template>
And I call this template from within client/main.html
{{> loginButtons}} {{#if currentUser}} {{> mainTabs}} {{/if}}
In client/main.js, I have a mainTabs Template helper that subscribes to the data:
weights: function() {return Meteor.subscribe("Weights");}
And finally, on the server side, I have server/main.js:
Meteor.startup(() => { Meteor.publish('Weights', function() { return Weights.find(); }); Meteor.methods({ addWeight: function(doc) { check(doc, Weights.simpleSchema()); Weights.insert(doc, function(err, docID) {console.log("DocID: ", docID);}); } }); });
I am able to type in a weight, but when I click submit, the weight does not get stored. The console.log(docID) will correctly print out the weight I typed in, so it seems that there is an issue with inserting. I’m not sure what is going wrong. Why am I not able to insert? Thanks for the help!