【发布时间】:2016-02-19 16:28:18
【问题描述】:
我在客户端有以下代码:
Meteor.call("getOldTests", m_user, test_id, course, language, function (error, result) {
console.log("result: " + result);
if (error) {
Notifications.error(error.reason, 'We are working on this problem');
} else {
console.log(result);
data.set(course, result);
}
});
其中服务器端有以下方法:
Meteor.methods({
getOldTests: function (m_user, test_id, course, language) {
var tests = Tests.findOne({email: m_user.email, course_en: course, test_id: test_id});
if (tests) {
console.log(tests);
return Questions.find({course_en: course, variant: tests.variant, language: language});
} else {
return false;
}
},});
其中变量data 是reactive-dict
那么,为什么在客户端我的 Meteor.call() 函数内部没有执行任何操作(没有控制台输出),而实际上它调用了服务器端的方法(控制台输出中间结果)?
谢谢,
【问题讨论】:
-
代码对我来说很好,复制应用程序或更多代码会有所帮助
-
出于好奇,这里为什么使用方法而不是
Meteor.publish()?看来你只是想返回一个光标。 -
@MichelFloyd 是的,你是对的!抱歉,我没弄明白。
标签: asynchronous meteor methods synchronization call