Tag: meteor

npm ERR! 404没有findnpm ERR! 不好的代码0

我刚开始制作一个angularmeteor的网站,现在我想用日历来select一个date。 从这个SO回答中,我得到了我安装使用的meteorangular度UI日历的提示 meteor add angularui:ui-calendar 然而,安装应用程序后,我的应用程序崩溃与消息说Error: Can't find npm module 'bcrypt'. Did you forget to call 'Npm.depends' in package.js within the 'npm-bcrypt' package? Error: Can't find npm module 'bcrypt'. Did you forget to call 'Npm.depends' in package.js within the 'npm-bcrypt' package? 。 所以我尝试使用以下变化安装 npm install npm-brcrypt npm install brcrypt 不幸的是,我总是得到一个错误说 npm ERR! 404 Not Found […]

处理meteor客户端的错误

我目前正在使用meteor-collection2而且我的validation系统出现错误。 在“lib”文件夹中,我定义了我的集合,并为其添加了一个SimpleSchema 。 然后,我定义了一个Meteor.method : # define methods Meteor.methods # create RecipeCommentCreate: (options) -> # find recipe recipe = Recipes.findOne(options.recipeId) if !recipe throw new (Meteor.Error)(404, 'Recipe not found') # init comment comment = message: options.message recipe: _id: recipe._id # insert comment RecipeComments.insert(comment) 所以,这个代码在client-side和server-side ,使用延迟补偿(这是完美的,因为collection2可以在双方工作)。 但是,在调用这个方法时(感谢客户端的事件): # call method Meteor.call 'RecipeCommentCreate', options, (error, result) -> if […]

meteor内部:光纤如何工作?

meteor大量使用光纤,每个客户的请求都在一个单独的光纤中运行,但是这实际上是做什么的? 从阅读各地纤维的好处看来,它们可以让你以同步的方式编写asynchronous代码。 这是他们所做的一切吗? 另外,this.unblock()如何在方法中工作? 该文档说:“在Meteor中,您的服务器代码在每个请求的单个线程中运行,而不是以Node的典型asynchronouscallback方式运行。 纤维如何模仿线程,而不是实际上是一个线程? 如果一个Meteor方法执行一个长时间的计算,它不会阻塞事件循环?

在多个订阅的上下文中处理客户端上的地理查询

我在我的应用程序中有两个不同的订阅: Meteor.subscribe('collection'); 和 Meteor.subscribe('filtered-collection',param1,param2); 我想通过不同的模板助手提供数据到不同的模板,分别说allResults和filteredResults 。 由于$geoWithin不能在客户端工作,我需要使用它进行过滤,所以我不能仅通过过滤第一个订阅 filteredResults = Collection.find(selector);` 因此,我需要一个单独的订阅。 所以,问题是:如何从各自的订阅中find结果集并将其传递给helper?

从事件更新无功variables

我在用着 Template.uploadFile.events({ 'change .set-file': function ( event, template ) { var file = event.currentTarget.files[0]; […] } }); 上传文件时。 我想读取文件中的每一行,并将每一行作为文档插入集合中。 问题是,我想react native地显示用户创build了多less行。 首先,我需要将文件中的行数设置为一个variables。 我必须在事件中设置variables,因为我只知道文件读取后的行数(即事件已经被触发)。 我想我必须做类似的事情 Template.uploadFile.helpers( { numRows: function () { return ?; }, numInsertedRows: function () { return ?; }, } ); 插入的行数可以是我的集合中的文档数量; 不过,我猜想在插入集合的同时,需要从集合中读取内存。 所以我认为最好只使用普通variables,因为所有的信息都可以在不询问数据库的情况下使用。 我有一个循环 rowsInFile.forEach( function ( row ) { // add 1 […]

meteor中的stream量路由器子导航

我有一个布局 <template name="default"> {{> header}} <aside class="container"> {{> Template.dynamic template=yield}} </aside> </template> 我使用stream量路由器导航到设置: FlowRouter.route( '/settings', { name: 'settings', action: function ( params, queryParams ) { BlazeLayout.render( 'default', { yield: 'settings' } ); }, } ); 但我的设置页面由多个设置页面组成,所以我需要在设置页面上的菜单,以便用户可以导航到其他设置页面(即更改密码,更改名称等)。 我将不得不为每个设置页面设​​置路线,但是如何在设置页面之间保留一个侧栏来导航? 路线是 /设置 /设置/更改密码 /设置/删除用户 等等 我认为用户应该能够在路线/settings的“主要/基本设置页面”上更改他/她的名字。 我想我可以做另一个有侧边栏的布局页面,所以我可以设置路线 FlowRouter.route( '/settings', { name: 'settings', action: function ( params, queryParams ) […]

meteor.js – 将点击元素的ID传递给一个集合

我用3个元素构build了一个页面,每个元素都是这样的: <div class="col-md-4 event-type"> <a href="{{ pathFor 'step2' }}" id="eventchoice" name="eventchoice" value="corporate"> </a> </div> 我试图通过使用以下代码将<a>元素的值或名称或ID传递给集合: EventsController.events({ 'click #eventchoice' : function(event) { console.log(event.target.getAttribute("id")); console.log(event.target.getAttribute("name")); console.log(event.target.getAttribute("value")); var eventchoice = event.target.value; var params = { eventchoice: eventchoice } //Insert Event Meteor.call('addEvent', params); FlashMessages.sendSuccess('Event Added'); } }); 我添加了console.log来查看是否可以获得<a>元素的id / name / value,但是控制台输出了所有这些的“null”。 因此,eventAdd方法中没有任何内容传递给集合。 我不相信问题是与EventsController,addEvent方法或Events集合。 任何想法如何我可以通过这些价值观? 感谢您的帮助!

使用GraphicsMagick处理GridFS文件并将其作为新文件存储

我试图通过gridfs-stream ( https://github.com/aheckmann/gridfs-stream )读取一个GridFS文件,用gm旋转它90°并将其作为一个新的GridFS文件存储。 我的结果看起来非常不稳定…所以我在寻求帮助来优化这个小小的代码片段。 而这个代码的第二件事:我需要一种“开关”。 这段代码对图像进行旋转操作。 但我需要传递参数来做旋转,resize或其他。 我如何整合这个? import Grid from 'gridfs-stream' import { MongoInternals } from 'meteor/mongo' const id = '12345' const gfs = Grid( MongoInternals.defaultRemoteCollectionDriver().mongo.db, MongoInternals.NpmModule ) const readStream = gfs.createReadStream({ _id: id }) readStream.on('error', function (err) { console.error('Could not read stream', err) throw Meteor.Error(err) }) gm(readStream) .rotate('#ffffff', 90) .stream(function (err, stdout, […]

如何在Meteor应用程序中“分离”长时间运行的服务器端function?

作为meteor应用程序的一部分,我有一个服务器端,通过向集合的插入/更新获取信息的POST消息,以提供给Web客户端。 到现在为止还挺好。 但是,有时这些更新可能相当大(每5秒logging一次,每次50K)。 直到我开始使用批处理插入包,然后使用Mongo的低级batch.find.update()和batch.execute()时,我一直很难保持这种状态。 但是,即使有5万条logging,它仍然有大量的处理过程(它会进行一些计算,分析等)。 我会喜欢能够“线程”的逻辑,所以主事件循环可以继续下去。 但是,我不确定是否有真正简单的方法在Meteor中为此创build“真实”线程。 因此,我想知道至less“批量”工作的最佳/适当的方式,以便每N(例如1K左右)logging我可以释放事件循环回来处理其他事件(如某些客户端DDP消息等)。 然后做另一个1Klogging等等,直到无论我需要多lesslogging完成。 我在想,解决scheme在于使用Fibers / Futures(似乎是Meteor的方式),但是我不是正确的,或者像“setTimeout()”和/或“setImmediate()”这样的低级思想是正确的更合适。 TIA!

使用npm包http-proxy在Meteor下设置SSL

我正在尝试使用SSL-Meteorpedia来设置SSLmeteor。 我已经安装了meteorhacks:npm,并在pakcages.json文件中定义了当前版本的npm http-proxy包。 现在我已经在服务器文件夹中设置了以下meteor方法: Meteor.methods({ 'ssl': function(options) { var fs, httpProxy, proxy; httpProxy = Meteor.npmRequire('http-proxy'); proxy = httpProxy.createProxyServer(options); fs = Meteor.npmRequire('fs'); http.createServer(function(req, res) { return proxy.web(req, res, { target: "http://" + this.connection.httpHeaders.host + "3000" }); }); proxy.on('error', function(e) { if (DEV_MODE) { return console.log(e); } else { return document.body = "The request couldn't be handled"; […]