12

When I create a meteor app, where is the database?

I have an app called leaderboard, but when I run mongo shell and do show dbs I see only local (empty) and test but test doesn't doesn't have the same contents as my leaderboard app. Where does meteor create the Mongo database and how can I access it from mongo shell (so I can load some data into it)?

ChatGPT
  • 5,334
  • 12
  • 50
  • 69

3 Answers3

16

You need to be running the application with the meteor run command in one session, at which point you can run mongo meteor in another session on the same machine, which will include something like

[kfullert@shotgun ]$ meteor mongo
MongoDB shell version: 2.2.1
connecting to: 127.0.0.1:3002/meteor

At that point, you can use the URL in the "connecting to" line with the standard mongo tools (caveat - you need to be running your project with meteor at the same time, as "meteor run" is what spins up the mongo server for your project

[kfullert@shotgun ]$ mongo 127.0.0.1:3002/meteor
MongoDB shell version: 2.2.3
connecting to: 127.0.0.1:3002/meteor
>

For mongoimport, you'll probably want something like:

[kfullert@shotgun ]$ mongoimport -h 127.0.0.1 --port 3002 -d meteor

Additionally, it may be possible to run mongoimport without meteor running, by using the following switch from your project root directory (untested so beware)

mongoimport --dbpath .meteor/local/db -d meteor
kgfullerton
  • 300
  • 1
  • 5
  • is it possible to run mongodb on the web browser? – S Gaber Jun 17 '14 at 18:59
  • meteor automatically runs minimongo (a lite, js version) in the browser, but you still need a server-side version mongodb for data sharing between clients – ChatGPT Dec 01 '16 at 09:12
8

For apps running a local db server, APPDIR/.meteor/local/db

7

You can connect to your app's mongodb with meteor mongo and then us show collections to list the Meteor.Collections you've created.

Rahul
  • 12,181
  • 5
  • 43
  • 64
  • do you know how I can run `mongoimport` against it? specifically trying to import a csv `mongoimport -d mydb -c things --type csv --file locations.csv --headerline` into my meteor database. can do it with a database which is not under meteor, but not able to do it with a meteor db. – ChatGPT Mar 12 '13 at 15:00
  • is there any other way? I can't run `mongoimport` from that shell. – ChatGPT Mar 12 '13 at 15:17
  • 2
    `mongoimport` isn't used from that shell. You need to download the full mongodb kit from 10gen @ mongodb.org and use the `mongoimport` utility , usually in the `bin` folder – Tarang Mar 12 '13 at 15:49