This code reports an error
var queryAll = user_model.find();
, I don’t know where the error is in this code, please help someone with experience,
// login action
const express = require('express');
var mongoose = require('mongoose');
var User_Model = mongoose.model('User_Model');
const router = express.Router();
router.get('/',(req,res,next)=>{
res.render('login.html');
});
module.exports=router;
router.post('/',(req,resp,next)=>{
debugger;
//连接数据库
mongoose.connect('mongodb://127.0.0.1:27017/likeread',(err)=>{
if(err)
console.log('err');
});
console.log(mongoose);
var user_model = new User_Model();
debugger;
//查找数据
var queryAll = user_model.find({});
queryAll.exec((err,result)=>{
if(err){
console.log(err);
}else{
console.log(result);
}
});
debugger;
user_model.close((err,res)=>{
if(err){
console.log(err);
}
});
debugger;
resp.end();
});