I am using meteor.js to write a large modular app. Inside my app, I have a collection named "Courses". The Schema of a object inside of the course collection looks like:
_id: MongoId
title: String
intro: String
content: Object
settings: Object
secret: Object
nonSecrets: Object
members: [Object]
userId: MongoId
wantsMail: Boolean
gotMemberAt: Date
I have several Publications:
# Publish an overview of all courses, I am Member at
Meteor.publish 'myCourses', ->
return Courses.find(
{members:{$elemMatch:{userId: @userId}}},
{fields:{title:1, intro:1, 'settings.nonsecret':1, 'members.$':1}}
)
# Single Course Detail
Meteor.publish 'singleCourse', (id) ->
return Courses.find(
id,
{fields: {title:1, intro:1, content:1, 'settings.nonSecret':1}}
)
# Admin Information of course
Meteor.publish 'singleCourseAdamin', (id) ->
return Courses.find(
id,
{fields: {title:1, settings:1, members:1}}
)
My problem is now, that when I subscribe to all three publications, I don't get other members than those of the myCourses
Publication.
Is there any good text about how publishing and subscribing to subsets of the same document work in actual meteor versions and what I need to check for if I want to make it work?
Or is there a package that make it easier to restrict the access to fields for each user?