everyone hoping to all are fine. I'm new to node.js and mongodb and i'm having trouble passing in variables to a mongoose model query.
When I pass two arguments, its result is empty and however the record exists.
Retrieving data from MongoDB Image
Sending Get Request through Postman
GET Route: /data/:vehicle_no/:drive_id
URL: http://localhost/api/data/ZXC-1123/drive_234
Route Code:
var reg_no = req.params.vehicle_no;
drive_id: req.params.drive_id;
vehicle.find({
ID: reg_no,
Trip_Details: {
FileName: drive_id
}
}, function(err, result) {
if(err) {
res.json(err);
} else if(result.length > 0) {
res.json("Drive id Found");
} else {
res.json("Drive id not Found");
}
})
Result: Drive id not found
However Expected Result must be: Drive id found
In the above code: Trip_Details is the objects array having file_name, _id, TripData.
And If I pass only one argument like vehicle.find({ ID: reg_no } then result found.
Kindly help, Thanks in Advance