How can I query an FS collection in Meteor from the command line?

862 views Asked by At

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.

2

There are 2 answers

0
giantsnyc On BEST ANSWER

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.

0
Greenhorn On

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