我有一个非常简单的模板,如下所示;在火焰模板中显示光标数据不适用于Meteor.call()
<template name="editingUsers">
<div class="container">
<div class="jumbotron">
<ul class="custom-list-stye">
{{#each lastEditors}}
<li><span><strong>{{docUser.name}}</strong></span> </li>
{{/each}}
</ul>
</div>
</div>
</template>
我用助手填充HTML中的列表;
Template.editingUsers.helpers({
lastEditors: function() {
return Meteor.call('getLastEditors');
}
});
'getLastEditors'方法通过MongoDB查询返回数据;
getLastEditors: function() {
if(Meteor.user()) {
const lastEditors = Documents.find(
{docUser: {$exists: true }},
{
limit:5,
sort: { lastEdit: -1 },
});
return lastEditors;
}
}
使用此代码,应该显示为列表的数据不会出现。但是,如果我直接从助手进行Mongo DB查询,一切都会变好。以下是工作帮手代码。 (该包自动发布不删除)
Template.editingUsers.helpers({
lastEditors: function() {
return Documents.find(
{docUser: {$exists: true }},
{
limit:5,
sort: { lastEdit: -1 },
});
}
});
如你所知,我不能包自动发布继续我要实现Meteor.methods()。我不明白为什么从Meteor.method返回的游标数据没有显示在模板中。我可以提出你的意见吗?
Thanks @ghybs for your comment! –
感谢您的反馈!如果答案确实解决了您的问题或提供了重要帮助,那么SO的感谢方式也是可以接受的答案。 – ghybs