mongoose.connect(process.env.DATABASE_URL, {useNewUrlParser: true});
const MyModel = mongoose.model(mymodel, new Schema({ name: String }));
This creates a database named 'test' and a collection named 'mymodel'. How to change the 'test' name of my database?
If you are posting data on remote mongoDB server, make sure you write Database name in connection url before "?retryWrites". There may be written as 'test' or nothing. If 'test' is there replace it with your database name, if not write database name just before '?' mark.
mongodb+srv://<username>:<password>@cluster0.vbaw8.mongodb.net/<database_name>?retryWrites=true&w=majority
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With