mongoose find all from array code example

Example: find all mongoose

//create model students

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) => {
	//fetch all data student
  STUDENT.find().then((p) => {
    res.send(p);
  });
};

exports.getProducts = (req, res, next) => {
	//fetch all data student
  STUDENT.find({},(err,p)=>{
  	 res.send(p);
  });
};