How can i find all docs in an array which have a certain value in an array like hobby's. How can i find for example all user which have ski as a hobby and is it also possible to find all who have golf and soccer in one statement or will i have to reduce array by first find all soccer and then find all who also pay golf ? The basic filter does not work and most samples i found only cover the case where the array has a key / value pair. Tried the below with no luck
const filteredData = data.filter(x => x.hobby(e => e ==='ski')
[{ "user" : 1,
"name" : "demo 1",
"hobby" : ["soccer", "golf", "ski"],
"age" : 24
},
{ "user" : 2,
"name" : "demo 2",
"hobby" : ["soccer", "ski"],
"age" : 27
},
{ "user" : 3,
"name" : "demo 3",
"hobby" : [ "ski"],
"age" : 21
},{ "user" : 4,
"name" : "demo 4",
"hobby" : ["soccer", "golf"],
"age" : 24
}]