Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript User Authentication With Express and Mongo User Registration Adding Data to the Database

Irena B.
Irena B.
8,713 Points

"show collections is not showing anything"

The command "show dbs" is not showing "bookworm" base.

show dbs admin 0.000GB config 0.000GB local 0.000GB

It seems like new base is not created. I have checked code few times, but probably problem is somewhere else..

2 Answers

Eric M
Eric M
11,546 Points

Hi Irena,

Can you post your node.js code that connects to / creates the bookworm db in Mongo?

Has this code executed before you are checking mongo?

Cheers,

Eric

Irena B.
Irena B.
8,713 Points

Hey, thanks for the answer! I have posted code below. I am running mongo on localhost:27018/ so use the command sudo mongod --port 27018,

Irena B.
Irena B.
8,713 Points
//mongodb connection
mongoose.connect("mongodb://localhost:27018/bookworm", { useNewUrlParser: true }); //default port for mongodb
mongoose.set('useCreateIndex', true)
const db = mongoose.connection;
//mongo error handler
db.on('error', console.error.bind(console, "connection error:"));