Reputation: 7708
Neither mongoose.connect('mongodb://localhost/sync-db');
nor mongoose.createConnection('mongodb://localhost/sync-db');
is creating the sync-db
on local host.
Though both connection callbacks are successfully connected. But when I tried to check both robo-mongo and mongod client console using the command show dbs
, the sync-db
is neither to be seen on robo-mongo nor on mongod client
WTF?
Upvotes: 0
Views: 472
Reputation: 7708
Since no one is answering this question, I will post my own answer based on what @Odonno said on the comment, which is correct.
The codes above use to create database is not wrong, in the background the database has already been created, but for some reason (I hope someone will explain this) you wont see it until you added some data to it.
Upvotes: 2