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.
As you know, because you posted the issue, this is a bug in meteor.
My workaround was to connect to my mongodb with the standard mongo client. You can find what port your db is running on by looking at the file yourapp/.meteor/db/METEOR-PORT
and then just run mongo localhost:[put that port number here]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With