Javascript 使用Meteor.publish筛选用户访问的数据
我需要帮助:我无法使(Meteor.publish)工作来过滤页面数据和应用用户(所有者)添加的许可 现在,我向您展示我用Coffescript(publish.coffee)编写的代码,以及使用包(aldeed:tabular-)编写的用于DataTable的JSJavascript 使用Meteor.publish筛选用户访问的数据,javascript,meteor,coffeescript,Javascript,Meteor,Coffeescript,我需要帮助:我无法使(Meteor.publish)工作来过滤页面数据和应用用户(所有者)添加的许可 现在,我向您展示我用Coffescript(publish.coffee)编写的代码,以及使用包(aldeed:tabular-)编写的用于DataTable的JS 咖啡 reportpage.js reportpage.html {{>TABLART table=TABLARTABLES.DELERS class=“table table striped table BORDED table
{{>TABLART table=TABLARTABLES.DELERS class=“table table striped table BORDED table CONNECTED”}
我怎样才能修好它?
请帮帮我!:(尝试使用
选择器
筛选表格使用的结果
TabularTables.Dealers = new Tabular.Table({
name: "Dealers",
collection: Dealers,
columns:[
{data: "name", title: "Name"},
{data: "p_iva", title: "Partita IVA"},
],
selector: function (userId) {
if (!!userId) {
return {owner: userId}
}
},
}
有关更多信息,请参阅。尝试使用
选择器来过滤tabular使用的结果
TabularTables.Dealers = new Tabular.Table({
name: "Dealers",
collection: Dealers,
columns:[
{data: "name", title: "Name"},
{data: "p_iva", title: "Partita IVA"},
],
selector: function (userId) {
if (!!userId) {
return {owner: userId}
}
},
}
有关更多信息,请参阅。我是这样解决的:
Template.reportpage.helpers({
selector () {
if (!!Meteor.userId()) {
return { owner: Meteor.userId() };
}
},
});
我这样决定:
Template.reportpage.helpers({
selector () {
if (!!Meteor.userId()) {
return { owner: Meteor.userId() };
}
},
});
我不太了解CoffeeScript,但是.find接受JSON对象。因此,在publish方法中,derators.find({'owner':userId})。否则,它看起来像是在订阅数据之前获取呈现,尝试订阅路由上的数据或在呈现表之前检查是否订阅了数据。我尝试应用Meteor.publish“reportpage”,->derals.find{owner:this.userId},但所有用户的数据始终显示:(在我的情况下,只需要显示登录用户(owner)的输入数据。从应用程序中删除autopublish包。已删除,但不起作用:(我发现这是我的情况,但我不知道放在哪里:{userId:Meteor.userId()}请看这里:“您将传递{userId:Meteor.userId()}作为表上的选择器属性。”我不太了解CoffeeScript,但是.find接受JSON对象。因此,在publish方法中,deralers.find({'owner':userId})。否则,看起来您的HTML在订阅数据之前获取呈现,尝试订阅路由上的数据或在呈现表之前检查是否已订阅数据。我尝试应用此Meteor.publish“reportpage”,->Dealers.find{owner:this.userId},但所有用户的数据始终显示:(在我的例子中,只需要显示登录用户(所有者)的输入数据即可从应用程序中删除autopublish包。已删除,但不起作用:(我发现这是我的例子,但我不知道该放在哪里:{userId:Meteor.userId()}请看这里:“,然后您将传递{userId:Meteor.userId()}”我尝试了这个方法,但它没有正常工作。我在浏览器日志中看到一个“警告”,其他值也出现在表中,只包括所有者userId。我使用文档:selector(userId){return{owner:userId}})
然后我阅读了文档,我已经应用了它,但它不起作用,它返回表中所有用户的所有数据,@aldeed在问题13中提出的解决方案可以使用选择器解决问题,但我不知道如何应用它。对不起,我尝试了你的解决方案,我错过了“}”,你的解决方案中怎么会缺少它n、 但是,因为我猜代码没有正确执行,所以显示了所有用户数据:(我尝试了此操作,但没有正常工作我在浏览器日志中看到“警告”,表中显示了其他值,仅包括所有者userId。我使用文档:selector(userId){return{owner:userId})
然后我阅读了文档,我已经应用了它,但它不起作用,它返回表中所有用户的所有数据,@aldeed在问题13中提出的解决方案可以使用选择器解决问题,但我不知道如何应用它。对不起,我尝试了你的解决方案,我错过了“}”,你的解决方案中怎么会缺少它n、 但是,因为我猜代码没有正确执行,所以会显示所有用户数据:(
Template.reportpage.helpers({
selector () {
if (!!Meteor.userId()) {
return { owner: Meteor.userId() };
}
},
});