mongoose query error - Stack Overflow
迷茫
迷茫 2017-05-31 10:41:47
0
1
610

This code reports an errorvar 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();
});
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
Peter_Zhu

var queryAll = User_Model.find({});

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template