This is my publish.js
file in which I publish my collection:
const tags = Tags.find({title: {
$regex: `.*${searchString}.*`,
$options: 'i'
}}, {
sort: { counts: -1 }, limit: 3
});
console.log(tags.count());
return tags;
And this is my components which is subscribing to this collection:
this.tagsSubscription = this.subscribe('tags', () => [this.tag], function (err) {
that.tags = Tags.find().fetch();
});
So with this I get 2 different errors:
sort and limit are not working: I sometimes get more than 3 results and there are not sorted by 'counts'
the callback is not working properly. It's too fast, I get different result on client and server. I tried with this way,
onSuccess()
and withMeteor.autorun()
but with no luck. If I use asetTimeout
I can see the correct cursor
The title search is the only thing that seems working.