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 [email protected]
brew services start [email protected]
我剛剛users使用貓鼬通過快速服務器制作了一個集合。然后我在我的終端中打開資料庫來檢查內容。但是,我收到一個非常奇怪的錯誤,告訴我資料庫test未定義,即使 shell 告訴我我正在使用test資料庫。還說集合users沒有定義,但它在那里??
我究竟做錯了什么?
uj5u.com熱心網友回復:
你的命令是錯誤的。使用其中之一:
use test
db.users.find()
db.getCollection("users").find()
db.getSiblingDB("test").users.find()
db.getSiblingDB("test").getCollection("users").find()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/314279.html
下一篇:MongoDB多重/嵌套聚合
