Is it possible to create a new database in MongoDB with Mongoose?
Yes, you can specify the database name in your connection string.
db = mongoose.connect('mongodb://localhost/dbname1')
As soon as you create a record with that connection, it will create the new database and collections under the database name of 'dbname1'. If you wanted to create a new database, you can specify a different connection string:
db = mongoose.connect('mongodb://localhost/dbname2')
and that will create all your records under the name 'dbname2'. Your documents will not import over to dbname2, you will have to do an import of those records if you wanted to do that. Hope that helps.
If you want to create database for online cluster you also need to enter your database name when you pass the uri like:-
"mongodb+srv://<Username>:<Password>@resumeapp.3ditras.mongodb.net/<DatabaseName>?retryWrites=true&w=majority"