Hello all, so I have an input field where the user selects a checkbox, I am using the accounts-ui and accounts-password packages.
What I want to happen is that what the user selects to be entered into the database, and then when the user logs back in then their checked field is checked in.
I know that this should be done with methods and calling and the publish subscribe model for more security but I am starting from the basics.
So I know how to insert the data and have that working on a basic level:
Template.ccinfo.events({ //responses to events
Template.ccinfo.events({ //responses to events
'change input[type=radio]': function (event) {
numSpeeches = event.currentTarget.value //getting the seleced radio fields
numSpeechesleft = 10 - numSpeeches; //number of speeches left
if (Meteor.user()) {
Status.insert({
num_speeches: numSpeeches,
createdOn: new Date(),
createdBy: Meteor.user()._id
});
}};
})
This insert is working and it is okay for now (though what I need to happen is that when the user plays around with the checkboxes it just update the already existing entry for that user and not creates a brand-now one).
What I want to happen next is a way to access this data for next time. So I should be able to do this by using Status.find and then putting a parameter that the id in the collection has to match the current logged in user and then get it to return the data that I need (the num_speeches).
However this is not working for me when I use the code for find. How should I format this code?
Thanks and sorry for all the questions recently but this is great community!