var student = express.Router();
app.use('/student', student);
student.get('/get/:sr_no/:title/:topic_title', function (req, res)
{
var v1,v2,v3;
v1=req.params['sr_no'];
v2=req.params['title'];
v3=req.params['topic_title'];
var cursor = dbo.collection("chepters").find({"sr_no":v1}).toArray(function(err, result)
{
console.log(result);
res.send(result);
});
})
We are trying to find the collection in mongodb using parameter like following
var student = express.Router();
app.use(’/student’, student);
student.get(’/get/:sr_no/:title/:topic_title’, function (req, res)
{
var v1,v2,v3;
v1=req.params[‘sr_no’];
v2=req.params[‘title’];
v3=req.params[‘topic_title’];
var cursor = dbo.collection(“chepters”).find({“sr_no”:v1}).toArray(function(err, result)
{
console.log(result);
res.send(result);
});
})
but the variable v1 is not wokring instead if we put static value 1 in place of v1 the query is working. How to pass value as variable.
We want solution we are beginners in mongodb and node.js
Help us to find the solution.