for this query i am getting the result of all the documents where the sensor name id d
db.sensors.find( { "sensorData.sensorName" : { $regex : /d/i } } );
but when try usiing this query with nodejs route i am getting empty array back router.get('/api/sensorsDetails/isUnique/:sensorName',function(req,res){ console.log(req.params.sensorName)
SensorsModel.find({"sensorData.sensorName":{ $regex : /req.params.sensorName/i }},function (err,result) {
console.log(result)
if (err) {
res.send(err.stack)
}
else {
if(result.length>0){
res.send(JSON.stringify({ status: false}))
}else{
res.send(JSON.stringify({ status: true}))
}
}
})
please help whats is wrong with second query