Complete the code to import Mongoose in an Express app.
const mongoose = require('[1]');
You import Mongoose by requiring the 'mongoose' package. This lets you use Mongoose features in your app.
Complete the code to connect Mongoose to a MongoDB database.
mongoose.[1]('mongodb://localhost:27017/mydb');
createConnection instead of connect.open or start.The connect method is used to connect Mongoose to the MongoDB database.
Fix the error in defining a Mongoose schema.
const userSchema = new mongoose.Schema({ name: [1] });String without { type: String }.type empty or incomplete.Schema fields must be defined as objects with a type property specifying the data type.
Fill both blanks to create a Mongoose model and export it.
const [1] = mongoose.model('User', [2]); module.exports = [1];
The model variable is conventionally named User and the schema variable is userSchema. Export the model, not the schema.
Fill all three blanks to define a schema with a required email field and create a model.
const [1] = new mongoose.Schema({ email: { type: String, [2]: true } }); const [3] = mongoose.model('Contact', [1]);
require instead of required.The schema variable is contactSchema. The field option to make a field mandatory is required. The model name is Contact.