It is very useful to run meteor mongo
and query collections from the command line, for debugging purposes, etc.
从命令行运行meteor mongo和查询集合非常有用,用于调试目的等。
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.
最近,我添加了collectionFS包以在数据库中启用图像存储。但是,我无法从命令行查询数据库。
db.fs.collection_name.find()
is not doing the trick, and I can't seem to find the correct command anywhere.
db.fs.collection_name.find()没有做到这一点,我似乎无法在任何地方找到正确的命令。
2 个解决方案
#1
5
Go to the Meteor Mongo console: meteor mongo
转到Meteor Mongo控制台:meteor mongo
See all the collections that are available: show collections
查看所有可用的集合:show collections
Look for the one that has cfs.collection_name.files
寻找具有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.
选择具有您的集合名称的那个。例如,我正在使用带有gridFS的collectionFS for images。当我输入show collections时,我看到cfs_gridfs.images.files所以我只是这样做:db.cfs_gridfs.images.files.find()来查看这些文件。
Hope that helps.
希望有所帮助。
#2
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
.
如果您发现很难使用命令行或终端,那么MongoDB的UI就叫做Robomongo,它易于安装和使用。我使用Meteor的默认端口号,然后在Robomongo中使用它作为3001。
And the query to view collection here is same as db.collection_name.find()
.
此处查看集合的查询与db.collection_name.find()相同。
#1
5
Go to the Meteor Mongo console: meteor mongo
转到Meteor Mongo控制台:meteor mongo
See all the collections that are available: show collections
查看所有可用的集合:show collections
Look for the one that has cfs.collection_name.files
寻找具有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.
选择具有您的集合名称的那个。例如,我正在使用带有gridFS的collectionFS for images。当我输入show collections时,我看到cfs_gridfs.images.files所以我只是这样做:db.cfs_gridfs.images.files.find()来查看这些文件。
Hope that helps.
希望有所帮助。
#2
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
.
如果您发现很难使用命令行或终端,那么MongoDB的UI就叫做Robomongo,它易于安装和使用。我使用Meteor的默认端口号,然后在Robomongo中使用它作为3001。
And the query to view collection here is same as db.collection_name.find()
.
此处查看集合的查询与db.collection_name.find()相同。