Hey guys. I hope all is well.
I working on this project in which I plan to allow my users to change things like their email and other information which I collect upon account registration and place in a collection.
I have been trying to do so by using collection.update() but it I think the only way to do so is by using some information like the id from the current user logged in to do so. this is what I have tried:
Template.Account.events({
'click #email-change-btn': function () {
var newEmail = $('[name=email]').val();
Data.update({ _id:** this.userId**}, { $set: {email: newEmail}});
}
});
As well as:
Template.Account.events({
'click #email-change-btn': function () {
var newEmail = $('[name=email]').val();
Data.update({ _id: **Meteor.userId**}, { $set: {email: newEmail}});
}
});
but the change/update does not work. I am guessing its because the IDs do not match(it’s different from) the one created upon registration. I need something that is unique to each user (that’s why I want to use _id)
This one:
I HAVE THIS CODE IN THE CLIENT NOT THE SERVER SIDE. COULD THIS BE THE ISSUE. How would I fix it and make it work? I was desperate and tried ObjectId but no luck. What could I be doing wrong?
How can I fix this (i.e. change the information in the collection) and make it work for every user who decides to change information in the database such as their email.
So overall, all I want to be able to is change/update the information in the Mongo database for every user who wishes to.
Please feel free to ask for more information if needed.
Thank you in advance. I really appreciate it.