webn00b webn00b - 1 year ago 118
Node.js Question

Mongo shell does not show collections (command show collections) when insert through Node JS

This is my project


I have a Node JS app that involves using MongoDB. It works fine, as I tried inserting, finding, and printing data from MongoDB to the console in the Node JS file, server.js. However, if I open a Mongo Shell and type
show collections
, it would show nothing.

Here is how I establish MongoDB connection:

mongod --dbpath ...path-to-project/url-shortener/data

Here is the url I use to connect in my

var dbUrl = "mongodb://localhost:27017/url-shortener";

Answer Source

Maybe you should first pick a db

> show dbs

Then after using a datbase

>use db1

You will see its collections:

>show collections

Finally use it:

> db.collection1.find()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download