如何处理外部插入Meteor数据库?

SIk*_*wan 6 mongodb meteor

我们本周开始使用Meteor,非常渴望将它用于未来的项目.

虽然我们今天下午遇到了一块石头,但在我们的生态系统中,我们需要能够从外部节点/流星处理和插入mongodb内的数据.

我们的两个主要解决方案是在Hbase集群中使用MapReduce,以及解析CSV文件并在MongoDB中插入结果的python脚本.

现在,我可以在Meteor应用程序中使用MongoDB数据的唯一方法是通过Meteor(控制台或表单)添加数据.

让我们举一个简单的例子,我希望能够通过_id访问帖子.Iron Router工作正常,并提供帮助来构建URL.有了相同的助手,我可以从三种不同的用法中找到两种不同的结果.

ObjectId似乎是错误的,这是我之前遇到的三种情况:

http://0.0.0.0:3000/post/PAXEqRBB7RiNrdTTT => Inserted by Meteor, works fine
http://0.0.0.0:3000/post/ObjectId(526fe0701d41c894b9105bff) => Inserted by python, broken
http://0.0.0.0:3000/post/ObjectId(526fe0701d41c894b8715bff) => Inserted with meteor mongo shell
Run Code Online (Sandbox Code Playgroud)

所以我不能通过流星之外的东西访问MongoDB中插入的任何东西.

我在Github上发现了一些相关的问题,主要是这个问题:

https://github.com/meteor/meteor/issues/61

但它在8个月前关闭了,因为修复工作在路线图中.我正在使用最新版本的流星(0.6.6.2),这似乎还没有修复.

我的问题是我能找到什么样的解决方法?我不能在Python中调用像Meteor ObjectID生成这样的JS方法,那么什么是最好的解决方案呢?

我应该使用Node DDP应用程序来处理MongoDB的所有外部插入吗?

And*_*Mao 5

如果您希望直接与数据库交互,我不会提倡您正在采取的方法,这似乎基本上是构建一个API,通过一些连接中间件与数据库进行交互.

在我看来,你有两个选择.

1.直接对MongoDB进行更改.

这是最容易和最快的选择,因为几乎所有语言都有MongoDB绑定.如果您使用Mongo oplog设置Meteor,Meteor的oplog观察驱动程序会立即获取您对Mongo所做的更改.

2. Talk to the Meteor server using DDP.

This is probably the "correct" way to do things. It also has the advantage of allowing you to make RPC calls to the server as opposed to just doing database changes, so you can take advantage of all of the Meteor.methods you've defined already in your app.

See here for a really simple example of a Python DDP client. You'd need to take it a bit further to get full reactivity that a Javascript client would see..

Update: Meteor itself has a full-fledged DDP client now, and one way to run it is just as part of a normal Meteor server on Node. You can do anything a normal browser client would do. For example, see https://github.com/VirtualLab/cooperation-loadtest.