2016-04-21 82 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或出口而設置蒙戈網址你目前的問題。

相關問題