1

I have 3 important tables

#Vehicles ( Model Vehicle )
    - Id
    - Name
    - Description

#FilterOptions ( Model FilterOptions )
    - Id
    - GroupId
    - Name
    - Value

#VehicleTags ( Model VehicleTag ) 
    - Id
    - fId (Is linked to table FilterOptions)
    - vehicleId

I want to select a sepecific vehicle with id 1, that is not the hard part for me but im struggeling to get the following.

I also want to get all the filterOptions that a vehicle has.

The relation for that is a vehicle has multiple vehicleTags and a vehicleTag has one FilterOption.

How can i achieve something like this

vehicle: {
  id: 1,
  filterOptions: {
      // ....
  }
}

Any help or suggestions are welcome!

If u need any more details let me know!

w3_
  • 64
  • 1
  • 1
  • 14
  • "I also want to get all the filterOptions that a vehicle has." This part is not clear, do you mean you want to get only the `vehicle` with `id=1` and still get all values in `filterOptions`? – Ibrahim Hammed Nov 15 '22 at 13:50
  • `hasOneThrough` is for a 1-1-1 relationship, a singular version of `hasManyThrough` which dealt with 1-m-m ("m" denoting many). your table looks like more of 1-m-1 with `Vehicles`(1)-`VehicleTags`(m)-`FilterOptions`(1). so, i'm not sure if you can have only single `FilterOptions` for a single `Vehicle`. cmiiw. – Bagus Tesa Nov 15 '22 at 14:54
  • @IbrahimHammed i want to get a vehicle with all the linked filterOptions through vehicleTags – w3_ Nov 15 '22 at 16:04
  • @BagusTesa ahh that makes sense, thanks, ill try to fix it in another way – w3_ Nov 15 '22 at 16:04

0 Answers0