0

Hi Meteor newbie here.

As I am prototyping an app, I get issues accessing a remote database on the client side of my app. More specifically, I run meteor MONGO_URL="mongodb://__id__:__pwd__@__address__.mlab.com:21010/meteor" meteor

and have in a public folder the following :

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

which yields the correct number in the meteor shell and 0 in my browser. Now I have seen here that the cause might a

lag between the client starting and the data being published

However, when I try console.log(Collection.find().count()) in my browser console, I get that same 0.

For the record, I have left autopublish and insecure untouched.

Would be glad to here any recommendations!

Community
  • 1
  • 1
FizBack
  • 33
  • 7
  • That should work just fine in browser console, if you have autopublish enabled. By "server console" you mean "meteor shell", not the mongo shell, right? – aedm Apr 21 '16 at 09:06
  • Weird indeed. Sorry for the imprecision, I do mean meteor shell. I also tried to connect to a local mongo database with the same method and sadly the same results. – FizBack Apr 21 '16 at 11:56
  • if you are using the database of another Meteor application, you can use `DDP.connect` – corvid Apr 21 '16 at 12:56

1 Answers1

0

You can create a bash file like this. If you don't have any setting.json file please remove that from the last line.

#!/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__:__pwd__@__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__:__pwd__@__address__.mlab.com:21010/meteor
export DEV_ENV="development"


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

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

You can also directly run using comment like In liunx

export MONGO_URL=mongodb://__id__:__pwd__@__address__.mlab.com:21010/meteor
meteor

In windows

SET export MONGO_URL= mongodb://__id__:__pwd__@__address__.mlab.com:21010/meteor
meteor

As per you current problem you are missing SET or export while setting mongo url.

Pankaj Jatav
  • 2,158
  • 2
  • 14
  • 22