- i am new to mongo db.
- I am trying to render my toyota car manufacturer alone.
written mongo db query code but its not producing results. var cursor = db.collection('user-data').find( { carManufacturer: { $eq: toyota } } );
can you guys tell me how to fix it providing my code below
router.get('/cars', function(req, res, next) {
console.log("kumari5");
res.render('cars.hbs');
var toyota = [];
mongo.connect(url, function(err, db) {
assert.equal(null, err);
var cursor = db.collection('user-data').find( { carManufacturer: { $eq: toyota } } );
cursor.forEach(function(doc, err) {
assert.equal(null, err);
toyota.push(doc);
}, function() {
db.close();
res.render('data', {items: toyota});
console.log(toyota);
});
});
});
{
"_id": ObjectId("590a2495bd1d3a356074d36e"),
"DateBough": "21",
"Owner": "Female",
"carManufacturer": ["toyota", "19"],
"Expiry": null
}
{
"_id": ObjectId("347834783478873478788734"),
"DateBough": "21",
"Owner": "Female",
"carManufacturer": ["bmw", "19"],
"Expiry": null
}
{
"_id": ObjectId("34634738468299221182338989"),
"DateBough": "21",
"Owner": "Female",
"carManufacturer": ["benz", "19"],
"Expiry": null
}
{
"_id": ObjectId("47347347834783487437834734"),
"DateBough": "21",
"Owner": "Female",
"carManufacturer": ["toyota", "19"],
"Expiry": null
}