2016-04-21 83 views
0

嗨流星新手在这里。当访问远程数据库时流星差异客户端和服务器端

当我正在创建一个应用程序原型时,在我的应用程序的客户端访问远程数据库时出现问题。更具体地讲,我跑流星MONGO_URL="mongodb://__id__:[email protected]__address__.mlab.com:21010/meteor" meteor

,并在下面的公用文件夹:

Collection = new Mongo.Collection("collection"); console.log(Collection.find().count());

它产生在我的浏览器流星外壳和0正确的号码。现在,我已经看到here的原因可能在客户端启动和数据之间的

滞后被发表

然而,当我尝试console.log(Collection.find().count())在我的浏览器控制台,我得到同样的0

有记录,我已经将autopublishinsecure保持原样。

很高兴在这里有任何建议!

+0

这应该在浏览器控制台中正常工作,如果您启用了自动发布功能。 “服务器控制台”是指“流星壳”,而不是mongo shell,对吧? – aedm

+0

真的很奇怪。对不准确的,我的意思是流星壳。我也尝试使用相同的方法连接到本地mongo数据库,结果令人难过。 – FizBack

+0

如果您正在使用其他Meteor应用程序的数据库,则可以使用'DDP.connect' – corvid

回答

0

您可以像这样创建一个bash文件。如果你没有任何setting.json文件,请从最后一行删除它。

#!/bin/bash 
: # This shell script runs on both Windows CMD and Bash. The system-specific sections are marked by 
: # comments, and share the final invocation of meteor 

:<<"::CMDLITERAL" 

@ECHO OFF 
REM This is the CMD section 
ECHO Running in CMD mode 
SET export MONGO_URL= mongodb://__id__:[email protected]__address__.mlab.com:21010/meteor 
SET DEV_ENV=development 
GOTO :COMMON 
::CMDLITERAL 

# This is the Bash section 
echo Running in Bash mode 
export MONGO_URL=mongodb://__id__:[email protected]__address__.mlab.com:21010/meteor 
export DEV_ENV="development" 


:<<"::CMDLABEL" 
:COMMON 
::CMDLABEL 

meteor run --settings settings.json --port 4000 

您也可以直接运行使用评论像 在LIUNX

export MONGO_URL=mongodb://__id__:[email protected]__address__.mlab.com:21010/meteor 
meteor 

在windows

SET export MONGO_URL= mongodb://__id__:[email protected]__address__.mlab.com:21010/meteor 
meteor 

按照你缺少SET或出口而设置蒙戈网址你目前的问题。

相关问题