I got a problem with publications and async functions. I started updating my App Framework to Meteor 3.0 by switching to planning:roles 4, wich now does not allow for sync functions server-side (duh). Meteor is still at 2.16.
So userWithIdIsInRole
has to be async now, wich in turn makes the whole publish function async.
Meteor.publish(`${sourceName}.rows`, async function({search, query, queryUiObject, sort, limit, skip}) {
if (!async(userWithIdIsInRole({
id: this.userId,
role: viewTableRole
}))) {
return this.ready();
}
return this.autorun(function(computation) {
var pipeline;
pipeline = getRowsPipeline({
pub: this,
search,
query,
queryUiObject,
sort,
limit,
skip
});
return ReactiveAggregate(this, collection, pipeline, {
clientCollection: `${sourceName}.rows`,
debounceDelay: debounceDelay,
noAutomaticObservers: noAutomaticObserves,
observers: typeof observers !== "undefined" && observers !== null ? observers : []
});
});
});
This of course leads to this Error:
Exception from sub users.rows id S2H8rLwbcqk6EvwZB Error: Publish function can only return a Cursor or an array of Cursors
I have no Idea how to solve this…