Every user in our database has specific skills assigned to them. We maintain a list of available skills with unique IDs. The objective is to filter users based on the skill we are interested in, like displaying all Janitors.
We are utilizing Vue.js and implementing this filter as a computed property.
This is what I have so far:
filteredResults() {
return this.users.filter(user => this.searchedSkills.some(skill => user.skills.some(userSkill => userSkill.id == skill.id)));
}
The issue seems to be with "user.skills.id". I intend to express: user.skills[*].id, but that syntax is invalid.
How do I identify users where one of their skills matches the selected skill's ID from a search dropdown?
Our data structure looks something like this:
Users: [
user1: {
name: "Tom",
id: "12345",
skills: [
0: {
title: "Programmer",
id: "12345678"
},
1: {
title: "Janitor",
id: "6788012"
}
]
},
user2 {
name: "Bill",
id: "u0wb0fu3b",
skills: [
0: {
title: "Landscaper",
id: "234525"
},
1: {
title: "Janitor",
id: "6788012"
}
]
}
]
SearchedSkills: [
0: {
title: "Landscaper",
id: "234525"
},
]