Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access Meteor's MongoDB from another client, while Meteor is running?

I would like to access Meteor's MongoDB from a Python client, while Meteor is running.

I can't start a mongod because Meteor's database is locked.

How do I access the database from another client?

like image 711
Joseph Turian Avatar asked Apr 24 '12 07:04

Joseph Turian


2 Answers

The meteor command provides a clean way. To get the URL for the running mongod:

meteor mongo -U 

which you can parse from python.

like image 123
debergalis Avatar answered Oct 08 '22 02:10

debergalis


Meteor starts the mongod for you on port 3002 when you run the meteor command, and stores the mongo data file in .meteor/local/db

Output from ps aux | grep 'mongod' shows the mongod command that meteor uses:

/usr/local/meteor/mongodb/bin/mongod --bind_ip 127.0.0.1 --smallfiles --port 3002 --dbpath /path/to/your/project/.meteor/local/db

So just connect your mongo client accordingly. In python:

>>> import pymongo
>>> con = pymongo.Connection(host='127.0.0.1', port=3002)
>>> con.database_names()
[u'meteor', u'local']

UPDATE: unfortunately making changes directly in mongo in this way won't reflect live in the app, but the changes will be reflected on a full page (re)load.

like image 25
danny Avatar answered Oct 08 '22 01:10

danny