I don't have any experience with updateaf in particular, but I have done a lot with Meteor.
I assume that you are wanting to only display the currently-logged-in user's information and allow them to update it?
If so, I think you would want to have a publication that only publishes the current user's info (using Meteor.userId()
, and you would likely have to link the People object's ._id to the Meteor userId), and then have that data automatically selected.
Changed parts from the Javascript section on the link you provided (https://autoform.meteorapp.com/updateaf):
Original (Only showing pertaining stuff that deals with selectedPersonId
, rest is all on the link):
Meteor.publish(null, function () {
return People.find();
});
Template.updateaf.helpers({
selectedPersonDoc() {
return People.findOne(Session.get("selectedPersonId"));
},
isSelectedPerson() {
return Session.equals("selectedPersonId", this._id);
}
});
Template.updateaf.events({
'click .person-row'() {
Session.set("selectedPersonId", this._id);
}
});
Change to (Rather than displaying all users and allowing them to change by clicking, just return the single one that corresponds to the Meteor User) (You might have to change/remove some other js functions to get rid of the "People List"):
Meteor.publish(null, function () {
return People.findOne({ _id: Meteor.userId() );
});
Template.updateaf.helpers({
selectedPersonDoc() {
return People.findOne({ _id: Meteor.userId() );
}
});
Please let me know if you have any questions, I hope this helps.
Some additional tutorials if you want:
https://guide.meteor.com/data-loading.html
https://themeteorchef.com/tutorials/publication-and-subscription-patterns