Here, we will write a program to create database in mongoose from node js, considering that the connection has already been mad.
app.js
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/myDatabase', { useNewUrlParser: true });
const mySchema = new mongoose.Schema({
name: String,
age: Number
});
const MyModel = mongoose.model('MyModel', mySchema);