BiozterzCodes
BiozterzCodes

Reputation: 205

Mongo shell keep passing document into default database "test". Eventhough I've already set to another database

I've set mongo database to current database using use currentdb. When inserting data from local host. The data keeps entering into default database "test".

Upvotes: 0

Views: 1158

Answers (1)

Joe
Joe

Reputation: 28366

Running use <databasename> in the shell affects only the current session.

If you then connect with node.js/mongoose and use .save(), that will be a separate session.

To find out the database being used by a mongoose connection, check the name property.

To set the database name when connecting, specify the name in the URL like:

mongoose.connect('mongodb://user:pass@localhost:port/database');

Upvotes: 2

Related Questions