使用节点ddp-client从Node插入流星集合 [英] Using node ddp-client to insert into a meteor collection from Node

查看:68
本文介绍了使用节点ddp-client从Node插入流星集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过node.js将一些syslog数据流式传输到Meteor集合中.它工作正常,但是Meteor客户端的轮询周期约为10秒,对于我的品味来说,这个周期太长了-我希望约为1秒.

I'm trying to stream some syslog data into Meteor collections via node.js. It's working fine, but the Meteor client polling cycle of ~10sec is too long of a cycle for my tastes - I'd like it be be ~1 second.

通过控制台的客户端集合插入速度很快,并且所有客户端都使用DDP进行即时更新.但是,直接从服务器端插入MongoDB会受到客户端轮询周期的限制.

Client-side collection inserts via console are fast and all clients update instantly, as it's using DDP. But a direct MongoDB insert from the server side is subject to the polling cycle of the client(s).

因此,目前看来,我只限于使用DDP从节点守护程序插入更新.

So it appears that for now I'm relegated to using DDP to insert updates from my node daemon.

在ddp-client软件包示例中,我可以看到我已订阅的消息,但看不到如何通过DDP和node.js,从而立即更新所有客户端...

In the ddp-client package example, I'm able to see messages I've subscribed to, but I don't see how to actually send new messages into the Meteor collection via DDP and node.js, thereby updating all of the clients at once...

是否有任何示例或指导?我将不胜感激-作为Node和Meteor的新手,我很快就达到了极限.

Any examples or guidance? I'd greatly appreciate it - as a newcomer to node and Meteor, I'm quickly hitting my limits.

推荐答案

根据此截屏,可以简单地调用集合声明的流星方法.在您的情况下,代码如下所示:

According to this screencast its possible to simply call the meteor-methods declared by the collection. In your case the code would look like this:

ddpclient.call('/counts/insert', [{hits: 1111}], function(err, result) {
    console.log('called function, result: ' + result);
})

这篇关于使用节点ddp-client从Node插入流星集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆