I'm trying to make a search option by name in node.js and it will search local database, if it finds the name it will display in webpage. But I'm getting the error in this syntax : user.find({id : findname}, which I have used in below code.
router.get('/', function(req, res, next) {
var findname = req.body.findname;
res.render('detail', { title: 'Detail' });
});
mongoose.connect('mongodb://localhost/student');
var testSchema = new mongoose.Schema({
id : Number,
name : String,
email : String,
age : Number,
college : String
});
var user = mongoose.model('stud', testSchema, 'stud');
router.post('/show', function(req, res){
user.find({name : findname}, function(err, docs){
res.render('detail',{users:docs});
});
});
findnamedeclared after it is used?