I’m new to Meteor and programming, if this doesn’t make sense or you need more info please let me know.
I’m loading a profile page of another user. So I have 2 userIds; this.userId and the other users Id. I want to use autoValue to save both userIds when an action is taken. I can’t figure out how to set the other users id even though I can display it on the html page.
The pattern to add the logged in user’s id through autoValue is only possible because Meteor tracks the logged in user automatically, on both the client and server, so it’s available to the schema at invocation. You need to attach the id of the other user before you insert the document.
Thanks for that #ergusto. That sort of makes sense to me. Would you mind showing me how to do it in the example below. I’ve been trying to figure to use defualtValue to grab the helper but that isn’t working either.
You can’t use defaultValue or autoValue in that way. Template helpers can only be called from the template. You need to set that field when you actually create the object.
const attrs = {
studentProfileId: 'some id value',
}
Collection.insert(attrs);