I'm sorry for this (peraphs) stupid question ... I install meteor and mongodb in my windows computer and i start to write some apps. I don't understand how to use mongo for shoving my db app ... i open one shell in my app dir and launch mongod, in one more shell in the same folder i start mongo.
show dbs
local
use local
switched to db local
show collections
startup_log
system.indexes
Where are my collections? Where is users collection?
When your app is running use this command on a separate command line mongo 127.0.0.1:3001
Meteor keeps the collections in this server. After you run mongo on this server, by writing use meteor you can use db specific to your running app. And then you can display your collections with db.getCollectionNames()
Meteor uses a library called Minimongo that's why it doesn't display if you run show dbs on your mongo shell.
By default it points to port 3001 hence if you are using Robomongo you can just make the set up to watch that port.
To display all your MongoDB collections using the shell, you may check this answer:
How to list all collections in the mongo shell?
You may also use a MongoDB GUI Tool such Robomongo
Related
When I go into "meteor mongo" OR "mongo localhost:3001", a shell opens up. If I 'show dbs', it displays:
customers 0.000GB
local 0.008GB
meteor 0.002GB
I created a collection during tinkering from within the shell and that currently is visible. What isn't visible, however, are the several collections that exist in my app! For example, in my meteor app, from localhost, I get a return of documents when I type 'Jobs.find().fetch()' and 'Tasks.find().fetch()'. If I update these documents, it persists after the app has been restarted.
These collections DO exist, but I don't know how to access them via shell.
You can access your collections like that:
> use meteor;
> db.myCollection.find();
try using robomongo. remember first to have meteor running
I am using iron router and unfortunately every time i cd into a directory generated by iron cli,i am notified i am not in a meteor directory.
So i have tried iron mongo and opens
> meteor mongo
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/meteor
but has been this way for the last five minutes. Is there an alternative way to access the mongodb that comes with meteor or what should be done incase you are using iron router?.
In my case,i just want to see how many collections i have like
show collections
I think is best way for you it is use some Admin UI. Check "mongodb admin ui" in google for variants.
For my part I can recommend:
Robomongo
Its is really perfect mongo manager. Native and cross-platform MongoDB manager
Whatever platform you use today — Robomongo is available for you. Distributed as a native application, fast and snappy Robomongo uses very little of your machine resources.
But if you find some critical for you bugs, try another perfect tool
MongoVUE
MongoVUE is an innovative MongoDB desktop application for Windows OS that gives you an elegant and highly usable GUI interface to work with MongoDB. Now there is one less worry in managing your web-scale data.
Grab the local mongo connection string first then connect as follows
God#God-HP-EliteBook-2540p:~/crud$ iron mongo
> meteor mongo
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/meteor
^C
God#God-HP-EliteBook-2540p:~/crud$ mongo mongodb://127.0.0.1:3001/meteor
Feed commands
God#God-HP-EliteBook-2540p:~/crud$ mongo mongodb://127.0.0.1:3001/meteor
MongoDB shell version: 3.2.4
connecting to: mongodb://127.0.0.1:3001/meteor
meteor:PRIMARY> show collections
Cannot use 'commands' readMode, degrading to 'legacy' mode
crud
meteor_accounts_loginServiceConfiguration
roles
system.indexes
users
meteor:PRIMARY> show dbs
admin (empty)
local 0.063GB
meteor 0.031GB
meteor:PRIMARY>
It is very useful to run meteor mongo and query collections from the command line, for debugging purposes, etc.
Recently, I have added the collectionFS package to enable image storage in the database. However, I am unable to query the database from the command line.
db.fs.collection_name.find() is not doing the trick, and I can't seem to find the correct command anywhere.
Go to the Meteor Mongo console: meteor mongo
See all the collections that are available: show collections
Look for the one that has cfs.collection_name.files
Choose the one that has your collection name. For example, I'm using collectionFS with gridFS for images. When I type show collections, I see cfs_gridfs.images.files so I just do: db.cfs_gridfs.images.files.find() to see those files.
Hope that helps.
If you find it difficult to use the command line or terminal, you have a UI for MongoDB called Robomongo which is easy to install and use. I use Meteor with its default port number and then in Robomongo it is used as 3001.
And the query to view collection here is same as db.collection_name.find().
I have started looking at Meteor and tried out some examples, but I'm puzzled by something: I have installed Meteor and not MongoDB on my machine, but Meteor seems to create its own instance of MongoDB.
How does this work?
Am I able to develop a separate application that can also perform CRUD operations on this database that Meteor is spinning up?
Meteor is shipped with a MongoDB installation
I think you can. The meteor mongo command gives the MongoDB URL to the database Meteor spins up.
meteor command will start its own instance of MongoDB.
You can then use meteor mongo to connect to the MongoDB database, which is usually running on the application's port+1, for example, app:3000 -> mongodb#:3001. So you could use any MongoDB tool to connect (for example, robomongo).
$ meteor mongo
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:3001/meteor
I would like to have two separate applications use the same Mongo DB instance, and since I am developing them at the same time I would like to be able to share the same development DB instance.
I realize that each instance of Meteor would have to run on it's own port. Is there a way to force meteor or mrt to connect to a local socket like the system version of MongoDB?
Yeah, you can just start meteor with the MONGO_URL parameter like:
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor
or
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor --port 4000
This assumes you have mongodb installed on your system. See this question for ways to make this process a little easier by using environment variables or a start script.
David's answer is in the right direction, but threw me off a little. Instead, we're doing this to start the first app as normal:
$ meteor
Then to start the second app and connect to the database of the first, we're doing:
$ MONGO_URL="mongodb://localhost:3001/meteor" meteor --port 3002
The key here is that meteor starts its own mongo instance on port 3001, and we can connect to that directly from a second meteor instance. David's answer uses your system's mongo for both apps.