In my app, a Meteor.user
can belong to several Organizations
. I’d like to send each user email digests for each organization they belong to at a scheduled time each day.
For additional context, right now I have an organizations
field that hangs off Meteor.user()
, which I use for a few different .find()
queries, and is just an array, e.g.:
organizations: [org1Id, org2Id]
What’s the best way to model this?
Here are a few options that come to mind:
- Add the preference to the
organization
field that hangs offMeteor.user()
. So something like
organizations: [
{_id: org1Id, preferences: {morningDigest: true, eveningDigest: false}},
{_id: org2Id, preferences: {morningDigest: false, eveningDigest: false}}
]
This would require me to use dot notation syntax to query the preferences. I thought I read somewhere though that using the dot notation syntax had some downsides. It would also require changing some of my existing .find()
queries.
- An alternate of the above would be to create a new field on
Meteor.user()
. Something like:
preferences: [{organizationId: org1Id, morningDigest: true, eveningDigest: false}, {organizationId: org2Id, morningDigest: false, eveningDigest: false}]
- set up a new
Preferences
collection where each document would have something like:
_id: 123
userId: userId,
organizationId: organizationId,
morningDigest: true,
eveningDigest: false
Maybe there’s another option that would be even better than the above. Appreciate any insight y’all might be able to offer.