How to call action on select option? MERN

Viewed 27

I would like to make an application for selling cars. I would have 2 select boxes, one would contain the car brand (BMW, Audi, Porsche ...) and the other would contain the car models (320d, A6 ..). The first question is how to make a mongoose model for such a select? Do I have to write something like this:

const BrandSchema = mongoose.Schema(
  {
    brand: { type: String, enum: ['bmw','audi'...], required: true },
    ......
  },
  {
    timestamps: true,
  }
);

The second question, since my model depends on the brand, I am interested in how to dispatch the action that will give me the models that are in that brand. I have no idea how to do it, so if anyone can just give me some guidance on how.

0 Answers
Related