I'm creating a react app and I connected my backend mongo where I want to store all my car brands, year, models etc. In react I'm using the select tag and there I get everything that is in the db. DB running. However, whenever I press a specific car brand and try to pick the year with another select tag it shows me the years of all the other car brands. How can I do it so it only shows me years of that specific car brand? Should only show 2012.
My get function
carRoutes.route('/').get(function(req, res) {
Car.find(function(err, car) {
if(err) {
console.log(err);
} else{
res.json(car);
}
}).collation().sort({car_description:1});
});
My Schema
let Car = new Schema({
car_description: {
type: String
},
car_year:{
type: String
}
});