nothingisdead / meteor-elasticity

A customizable Elasticsearch client with Blaze templates
8 stars 2 forks source link

How is publish handled? #2

Open isAlmogK opened 9 years ago

isAlmogK commented 9 years ago

Is is possible to pass custom Mongo Selector to the search or publish function like so

Meteor.publish('producers', function(options) {
    check(options, {
        sort: Object,
        limit: Number
    });
    var user = Meteor.users.findOne(this.userId);
    return Producers.find({organizationId: user.organizationId}, options);
})  
nothingisdead commented 9 years ago

You should be able to pass in a publish function (the second argument to Meteor.publish) as the third argument to index and have it work normally, though I haven't tested that functionality very thoroughly. However, The only argument passed to your function will be the internal representation of the index, so there isn't a way to pass in the options argument.

One solution would be to add another optional parameter called e.g. publish_options and store it on the internal representation of the index (which gets passed to the publish function automatically).

Thanks!