nicole@MacBook-Air client % mongosh
Current Mongosh Log ID: 6167b26073f2085eee4554b6
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.3
Using Mongosh: 1.1.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------
The server generated these startup warnings when booting:
2021-10-13T15:36:00.307-07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------
test> show dbs
admin 41 kB
config 111 kB
local 41 kB
test 8.19 kB
test> use test
already on db test
test> show collections
users
test> test.users.find()
ReferenceError: test is not defined
test> users.find()
ReferenceError: users is not defined
test> 我刚接触mongo,我刚刚在我的Mac上安装了一个本地数据库(Big Sur 11.4)。
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
brew tap mongodb/brew
brew install mongodb-community@5.0
brew services start mongodb-community@5.0我刚刚使用mongoose通过express服务器创建了一个users集合。然后,我在终端中打开数据库以检查内容。但是,我收到一个非常奇怪的错误,它告诉我没有定义数据库test,尽管shell告诉我我正在使用test数据库。还说集合users没有定义,但它在那里??
我做错了什么?
发布于 2021-10-14 07:40:37
你的命令是错的。使用以下选项之一:
use test
db.users.find()
db.getCollection("users").find()
db.getSiblingDB("test").users.find()
db.getSiblingDB("test").getCollection("users").find()https://stackoverflow.com/questions/69565158
复制相似问题