4

What's the best way to do joins in Meteor/mongo? Use one of these packages, or something else:

publish-with-relations

https://github.com/erundook/meteor-publish-with-relations/blob/master/publish_with_relations.coffee

collection-helpers

https://github.com/dburles/meteor-collection-helpers

Stennie
  • 63,885
  • 14
  • 149
  • 175
Giant Elk
  • 5,375
  • 9
  • 43
  • 56

2 Answers2

3

I'm very familiar with PWR, but collection-helpers is new to me. It looks like the two are complimentary.

PWR solves the somewhat complex problem of publishing documents to the client via a reactive join based on arbitrarily complex relationships. See this question for more details.

collection-helpers appears to be a set of convenience functions added to the client to be used when traversing collection relationships inside of a template (given that the required documents have already been published). For example, if you have books and authors in separate (but related) collections, you can immediately get myBook.author.fullName inside of a template without having to type out the extra find for the author.

Community
  • 1
  • 1
David Weldon
  • 63,632
  • 11
  • 148
  • 146
  • OK got it. Collection Helpers doesn't do anything to reduce the # of docs pushed to the collection. That's where publish-with-relations comes in handy. – Giant Elk Jan 12 '14 at 05:30
0

currently the top popular solution in atmosphere seems to be publish-composite https://atmospherejs.com/reywood/publish-composite

Adil
  • 231
  • 3
  • 6
  • 1
    I think Meteor is soon going to add this functionality to their core supported packages. – Giant Elk Jul 15 '15 at 17:38
  • Not that "soon", but they just announced the creation of Apollo, some kind of middleware between the database and the application: https://medium.com/apollo-stack/apollo-8b7215bcab1c. It's based on GraphQL concepts, and therefore should remove the need for publications/subscriptions. With this approach, joins will be implicit. – Nico Prat May 02 '16 at 09:27