Search code examples
mongodbimagemeteorcollectionfsdatabase

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


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.


Solution

  • 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.