Vs Code is not showing collections which are added to local dbs

I am new to mongodb and learning. Facing this weired issue.
VS Code is not showing the collections which are added to the DB in local host. As a result, null result is coming whenever I write a query and run them in the playground.
But the same is showing in mongoshell and quries are getting executed without any issue.

Relevant screenshots are attached as artifacts.



2021-06-16T18:30:00Z

I think what is happening is that you are only running the selected line, which does not include the use() command to select the database. If you select both lines or just run everything then it will work.

As a side note, as show collections is not a valid JS statement you can’t use it in a script. You can use it as the only statement in the script but not in the middle of other JS code.

2 Likes

Hi, Massimiliano,

Thank you very much. Your solution worked.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.