3

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.

Community
  • 1
  • 1
forallepsilon
  • 429
  • 2
  • 16

2 Answers2

5

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.

giantsnyc
  • 203
  • 1
  • 7
1

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().

Greenhorn
  • 580
  • 6
  • 20