I'm trying to find all vehicles that have a string of accessories.
I have a comma sep string of optioncodes that represent selectedItems from an options List
optionsString:String = leather,stripes, ...
I have an ArrayCollection called vehicleOptions that contains a list of vehicle options one row per option
I need to retrieve all vehicles (VINs) that have, not one, but ALL of the optioncodes contained in the selected optioncodes string.
Any recommendations on how to do this?
Once I have a list of VINs, this will allow me to filter down another List of vehicles on the lot by only the vehicles that have ALL the selected options.
I think you can just brute force check it if there is < 1000 cars. Use indexOf to test each option against the option string.
If you had 1000’s of cars to test, I would probably convert each option to a bit in a bitmask.
indexOf should be fine for checking if one option exists. I was just struggling with how to track/store only vehicles that have ALL the items in the option string, not just one.
I'm thinking a VIN array to store only the VINs that have all the options. And basically removing the VIN if one of them is not found. If all of the options are found, keep it. Not sure if that will work. I'm planned to try this today.
Europe, Middle East and Africa