Reputation: 568
I am trying to return a collection data in mongoDB shell. These are the commands I have entered in the MongoDB shell:
> **show dbs**
local 0.000GB
messages 0.000GB
restapi 0.000GB
> **use restapi**
switched to db restapi
> **show collections**
messages
> **restapi.messages.find()**
The error:
2017-02-26T19:03:50.024+0200 E QUERY [thread1] ReferenceError: restapi is not defined :`
To show that I do have records in the messages collection, I am attaching a screenshot:
Why can't I view the collection contents?
Upvotes: 0
Views: 327
Reputation: 307
db is a keyword, not the db name. Try db.messages.find() If you want proper JSON, try db.messages.find().pretty()
Upvotes: 2