Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Caveat: What I am about to say is going to change in a future release of Meteor. We're currently overhauling the custom publisher API to make it easier to use, but in a way that breaks back-compatibility.</p> <p>That said...</p> <p>It looks like what you're trying to do is build a server-side join into the published collection "contents". Here, for reference, is the current code (as of 0.5.2) that publishes a cursor (for when your publisher returns a cursor object):</p> <pre><code>Cursor.prototype._publishCursor = function (sub) { var self = this; var collection = self._cursorDescription.collectionName; var observeHandle = self._observeUnordered({ added: function (obj) { sub.set(collection, obj._id, obj); sub.flush(); }, changed: function (obj, oldObj) { var set = {}; _.each(obj, function (v, k) { if (!_.isEqual(v, oldObj[k])) set[k] = v; }); sub.set(collection, obj._id, set); var deadKeys = _.difference(_.keys(oldObj), _.keys(obj)); sub.unset(collection, obj._id, deadKeys); sub.flush(); }, removed: function (oldObj) { sub.unset(collection, oldObj._id, _.keys(oldObj)); sub.flush(); } }); // _observeUnordered only returns after the initial added callbacks have run. // mark subscription as completed. sub.complete(); sub.flush(); // register stop callback (expects lambda w/ no args). sub.onStop(function () {observeHandle.stop();}); }; </code></pre> <p>To build a custom publisher that is joined with another table, modify the added callback to:</p> <ul> <li>check if the added object has the key you want to join by</li> <li>do a find in the other collection for that key</li> <li>call set on your subscription with the new key and value you want to be published, before you call flush. </li> </ul> <p>Note that the above is only sufficient if you know the key you want will always be in the other table, and that it never changes. If it might change, you'll have to set up an observe on the second table too, and re-set the key on the sub in the changed method there.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload