mongoose express js post
const express = require("express");
const route = express.Router();
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const noteSchema = new Schema({
note: {
type: String,
required: true
},
});
const noteModels = mongoose.model("note", noteSchema);
route.post("/", async (req, res) => {
const note = new noteModels({
note: req.body.note,
});
const saveNote = await note.save();
res.json(saveNote);
})
module.exports = route;