Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Switch lists/todos to use publish-composite? #48

Closed
tmeasday opened this issue Nov 20, 2015 · 2 comments
Closed

Switch lists/todos to use publish-composite? #48

tmeasday opened this issue Nov 20, 2015 · 2 comments
Assignees
Labels

Comments

@tmeasday
Copy link
Contributor

Something like:

Meteor.publishComposite('list/todos', function(listId) {
  check(listId, String);

  const userId = this.userId;
  return {
    find() {
      return Lists.find({_id: listId, {userId: {$or: [{$exists: false}, userId]}});
    },
    children: [
      {
         find(list) {
           return Todos.find({listId: list._id});
         }
      }
    ]
  };
});

This would mean:

a) We wouldn't need to have the userId denormalizer (we have a second denormalizer, so we still demonstrate the pattern)

b) We'd actually be using publish-composite, so we'd have an example to use

c) We'd also be showing how the authorization works

@stubailo
Copy link
Contributor

Yes, I think this is a great idea!

@tmeasday
Copy link
Contributor Author

Ok, it's done here #49

Probably the only downside (apart from no longer demonstrating the denormalizer pattern) is that now we need to do an extra list lookup for every mutation of a todo (although we probably don't need to look up the todo itself in most/all cases?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants