Tag: meteor

客户端/服务器通信如何与meteor/节点j工作

我正在学习meteor。 现在我想弄清楚如何客户端/服务器通信的工作原理,我有一个文件在[根] /服务器与所有信息连接到数据库(用户,密码,主机,端口)也我有以下行的代码来testing这个“沟通” var getUsers = function(name) { return "Hi. I'm " + name; }; 并在我的根文件夹中有: console.log(getUsers("Juan!")); 但是我收到“未捕获的ReferenceError:getUsers未定义”错误。 所以问题是,我在做什么错了???????? 提前感谢任何帮助或暗示

与服务器端meteor,为什么“模块”没有定义?

我正在使用一些节点代码 module.exports = a; 这使: ReferenceError: module is not defined 那么分别推荐的解决方法是什么? 我宁愿有一些简单的已知代码,而不是安装一个“神奇地”使这项工作的软件包。 这是怎么回事? meteor服务器代码以某种方式运行在不是节点? 我知道我们有纤维包装,但我不认为你可以“定义”一些对节点环境至关重要的东西? W20150202-16:07:12.555(-8)? (STDERR) /Users/dc/.meteor/packages/meteor-tool/.1.0.40.prjwsp++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:173 W20150202-16:07:12.555(-8)? (STDERR) throw(ex); W20150202-16:07:12.555(-8)? (STDERR) ^ W20150202-16:07:12.596(-8)? (STDERR) ReferenceError: module is not defined W20150202-16:07:12.596(-8)? (STDERR) at __coffeescriptShare (packages/dcsan:ribot/vendor/rivescript-js/lib/rivescript.js:2913:1) W20150202-16:07:12.596(-8)? (STDERR) at RiveScript (packages/dcsan:ribot/vendor/rivescript-js/lib/rivescript.js:2910:1) W20150202-16:07:12.596(-8)? (STDERR) at __coffeescriptShare (packages/dcsan:ribot/vendor/rivescript-js/lib/rivescript.js:2911:1) W20150202-16:07:12.597(-8)? (STDERR) at /Users/dc/dev/shumi/chatU/app/.meteor/local/build/programs/server/packages/dcsan_ribot.js:2937:4 W20150202-16:07:12.597(-8)? (STDERR) at packages/dcsan:ribot/both/startup.coffee:13:23 W20150202-16:07:12.597(-8)? […]

未来在节点中运行一系列asynchronousfunction需要什么地方?

以前,我使用future.wait()等待一个值,然后再return到下一个函数。 (我正在编写meteor的方式) 在读取节点的非阻塞I / O体系结构之后 ,我的下面的方法(它是否工作)完全失败了目的? 我正在做的是将下面的“请求”函数的返回结果传递给另一个函数。 相反,callback方法是最好的约定? 为什么我使用未来的唯一原因是因为使用return立即执行。 我想学习最好的做法,因为我认为我将来会增加额外的不必要的代码层。 如果我使用callback约定, callback(null, result) ,'callback'是否等待对象传递给参数? 我的代码使用未来等待结果: function requesting(perm_data) { var f = new future(); request.get('example.com/api/auth_user', { oauth: {consumer_key:'somekey', token: perm_data.oauth_token, token_secret: perm_data.oauth_token_secret } }, function response(error, response, body) { if (!error && response.statusCode === 200) { var bodyToJson = parser.toJson(body, options) var userId = bodyToJson.user.id return […]

在Meteor.JS创build第一个用户创build第二个用户

当用户从使用useraccounts:core软件包生成的表单中注册(第一个用户)时,我们如何自动创build第二个用户? Exception while invoking method 'ATCreateUserServer' TypeError: Cannot read property '_id' of undefined从Accounts.onCreateUSer运行Accounts.onCreateUSer会导致错误Exception while invoking method 'ATCreateUserServer' TypeError: Cannot read property '_id' of undefined Accounts.onCreateUser(function(options, user) { // Create Primary User if(!user.type) { // Set user.type as 'user' user.type = 'user' // Create Secondary User Accounts.createUser({ username: options.profile.slaveName, password: options.profile.slaveName, type: 'slave', profile: { firstName: […]

METEOR +铁脚手架引导程序包安装错误

当我尝试在Iron Scaffolding中安装一个包时,出现错误。 我试图安装的软件包是Twitter Bootstrap。

将参数从路由器传递给meteor的模板助手

我有一个路由器定义如下 Router.route('/profile/:input',function(){ this.render('profile'); }); 所以我可以得到调用this.params.input input的值。 我想在MongoDB上查询这个值并传递给模板Profile。 但是我怎么能把这个信息从路由器交给帮手呢? if (Meteor.isClient) { Template.profile.helpers({ data: function(){ //what to do?! } }); }

将ID存储在Meteor的反应数组中

我将一个文档ID存储在Meteor的反应词典( https://manual.meteor.com/#deps-creatingreactivevalues )中。 最初,我创build了字典,并将值设置为null : Template.templateName.onCreated(function() { this.state = new ReactiveDict; this.state.set('selectedId', null); }); 后来我设置了ID this.state.set('selectedId', id); 现在我需要存储多个ID。 我应该存储的ID为逗号分隔的string值(例如1,5,7,13 )还是有可能以某种方式存储反应数组? 我怎样才能最好地处理这个? 如果我把它作为一个逗号分隔的string存储,我怎样才能添加另一个ID到string或testingID是否在选定的ID之间?

用JavaScript语句构造一个select器

我从一些会话variables创build一个MongoDBselect器。 如果会话值为空,则select器不应包含该条件。 我有一个select器 return Session.get('title') ? { title: Session.get('title') } : {}; 它应该如此运作; 不过,我想过滤更多的会话值。 如果我添加另一个,我得到 var title = Session.get('title'); var age = Session.get('age'); if (title && age) { return { title: title, age: age }; } else if (title) { return { title: title }; } else if (age) { return { age: age } […]

Meteor.js服务器端代码可以响应客户端上的会话variables

有没有办法让服务器上的代码响应客户端上的Session.Valiable? 例如: if(Meteor.isClient() { Template.main.events({ 'click #appleBtn': function() { Session.set('fruit', 'apples') } }) } if(Meteor.isServer) { if(Session.get('fruit') == 'apples') { doSomething() } else { doAnotherThing() } } 我最初的想法是有一个客户端代码不断发送会话variables的值通过方法调用的服务器,但这似乎不是太高效。

如何在mongoDB集合中存储meteor助手,以及如何从mongoDB集合中提取meteor助手

如何在mongoDB集合中存储meteor助手,以及如何从mongoDB集合中提取meteor助手? 例如,我在Mongo集合中有以下字段。 "templateName":"hello {{userName}} <div> Welcome to Store</div>" 在我的.js文件中,我想要做的 userName:function(){ return "Foo"; }