mongodb nodejs show schema field code example
Example 1: mongoose schema
const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true
}
}, {
timestamps: true
})
const User = mongoose.model('User', UserSchema);
module.exports = User;
Example 2: node js + mongoose
await mongoose.connect('mongodb://localhost/my_database', { useNewUrlParser: true, useUnifiedTopology: true});