Cannot return a collection data in mongoDB shell

21 views
Skip to first unread message

Osher Dukarker

unread,
Feb 26, 2017, 1:12:20 PM2/26/17
to nodejs
I am trying to return a collection data in mongoDB shell.
This is 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:


What's wrong here?

Osher Dukarker

unread,
Feb 26, 2017, 8:14:06 PM2/26/17
to nodejs
Just got the answer.
I should write this instead:
db.messages.find()
Reply all
Reply to author
Forward
0 new messages