Mongo-DB doesn't support query with wildcards in a nested structure
like: course.roles.*subscribed.find()
To find all courses of a user and in the same time find all participants of a course
We probably need this to find subscribers in different roles for not using something like this:
find = _.extend(find, { $or : [ { "roles.team.subscribed" : listparameters.courses_from_userid}, "roles.participant.subscribed":listparameters.courses_from_userid} ]})
in a Data-structure that looks like this:
'roles': {
'team': { subscribed: [ 'FeeLing' ] },
'participant': { subscribed: [ 'FeeLing', 'Chrosle' ] },
'host': { optional: true, subscribed: [] }
}
If we change it to something like this:
'roles': ['team', 'participant', 'host']
'subscribed': [
{'user':'FeeLing', 'roles': ['team', 'participant']},
{'user':'Chrosle', 'roles': ['participant']}
]
it gets much more difficult to find all participants of a course.
So we think of creating a separate collection for subscriptions (back to relational):
{user_id: '123', course_id: '456', role: 'participant'}
{user_id: '123', course_id: '456', role: 'team'}
{user_id: '789', course_id: '123', role: 'participant'}
what is the con about this?
Here is the link to this question on stackoverflow: http://stackoverflow.com/questions/20409838/recommended-data-structure-for-not-querying-nested-data-in-node-js