svasva / meteor-publish-with-relations

Meteor.js SmartPackage to publish associated collections at once.
162 stars 30 forks source link

Reactive relations? #8

Closed dradovic closed 11 years ago

dradovic commented 11 years ago

Hi,

Thanks for sharing this very useful package. I have one question though. Are the relations that are published along supposed to be reactive as well? In your example, are newly inserted comments pushed automatically to the client?

Cheers

svasva commented 11 years ago

Sure they are!

dradovic commented 11 years ago

Is it working with arrays as foreign keys as well? I have a 'Group' structure, holding user IDs in its 'memberIds' array. And I publish the users belonging to a group like this:

Meteor.publish("groups", function(userId) {
  return Meteor.publishWithRelations({
    handle: this,
    collection: Groups,
    filter: {
      $or: [
        {
          ownerId: userId
        }, {
          memberIds: userId
        }
      ]
    },
    mappings: [
      {
        key: "memberIds",
        collection: Meteor.users
      }
    ]
  });
});

It seems that updating the memberIds array is not pushing the changes to the client.

svasva commented 11 years ago

I didn't test it with arrays as foreign keys, so not sure if that should work.

dradovic commented 11 years ago

So, shall I open another issue having exactly this as a topic? Are you going to test it?