1

I have a form with checkboxes in it. The checkboxes correspond to different events that will trigger alerts (think notification settings - email me if comment/follower/mention etc)

What's the best way to store whether a checkbox has been checked or not? Do I create a new collection and assign the user ID to the information or do I just add the checkboxes to the user document?

Also how can I actually go about actually storing which checkboxes were ticked?

Appreciate the help

Sean
  • 2,609
  • 1
  • 18
  • 34

1 Answers1

2

This sounds like basic user profile information. Assuming that's the case, just add these preferences into the user document as boolean variables under the profile key. Ex:

Meteor.users.update({ _id: Meteor.userId() },{ $set: { 'profile.notifyViaEmail': true }});
Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
  • Hi Michael, Thanks for the help. Storing them in the profile is cool because they aren't sensitive information - but I'm having trouble working out how to collect all the checkboxes. I have about 8 settings and I can't work out the best way to get the value from each one before inserting them to the profile. Got any ideas? Thanks – Sean Oct 17 '15 at 18:23
  • You could get clever with checkbox ids and automatically collect their values, [example](http://stackoverflow.com/a/1965137/2805154) – Michel Floyd Oct 17 '15 at 18:57