I'm trying to connect Meteor to an existing MongoDB. I can't duplicate the database or change its name, because is used by other app.
I know I have to set a MONGO_URL
environment var to connect with it. However, after I set it, Meteor is not connecting to the especiefied MongoDB database. I tried doing a .find()
but it does not return any docs. An .insert()
from the web console shows the info in the page, but it doesn't get inserted in the database. Here are the codes:
$ echo $MONGO_URL
mongodb://localhost:27017/autana_dev
./lib/models.js
Posts = new Meteor.Collection('posts');
./server/app.js
Meteor.publish('posts', function() {
return Posts.find();
});
./client/app.js
Meteor.subscribe('posts');
Template.main.posts = function() {
return Posts.find();
};
Any idea? Anyone? My Meteor version release is 0.6.4.1, and the MongoDB version is 2.4.1.
UPDATE: July 28
After running meteor with meteor run
, I opened a new console window within project directory to run a meteor mongo console. However, after running meteor mongo
I received the following:
mongo: Meteor isn't running.
This command only works while Meteor is running your application
locally. Start your application first.