get all new mongoose code example
Example: find all mongoose
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const StudentSchema = new Schema({
name: String,
dob: Date,
mobile: String,
address: String,
});
module.exports = mongoose.model("students", StudentSchema);
const STUDENT = require("../models/Student");
exports.getProducts = (req, res, next) => {
STUDENT.find().then((p) => {
res.send(p);
});
};
exports.getProducts = (req, res, next) => {
STUDENT.find({},(err,p)=>{
res.send(p);
});
};