Answers for "mongoose express js post"

0

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;
Posted by: Guest on June-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language