Create models folder
Create quotesModel.js
inside the model folder
Bring in mongoose
const mongoose = require("mongoose");
Create quote Schema
const mongoose = require("mongoose");
const quoteSchema = mongoose.Schema({
quote: {
type: String,
required: [true, "Quote is required"],
maxlength: [250, "Quote cannot be More than 250 Characters"],
trim: true,
},
author: {
type: String,
maxlength: [20, "Author's name canot be more than 10 characters"],
},
});
module.exports = mongoose.model("Quote", quoteSchema);
Export the schema
module.exports = mongoose.model("Quote", quoteSchema);