I'm trying to remove an object from an array of objects if a certain value exists in nested data.
The data being returned from the API is shaped like this:
Array [
Object {
"id": "/db/Shifts/123",
"applicants": Object {
"applicants": Array [
"/db/User/12",
"/db/User/13",
],
},
Object {
"id": "/db/Shifts/456",
"applicants": Object {
"applicants": Array [
"/db/User/12",
"/db/User/14",
],
},
Object {
"id": "/db/Shifts/789",
"applicants": Object {
"applicants": Array [
"/db/User/13",
"/db/User/14",
],
},
]
Using Ramda, how would I filter out the shifts where User 12 exists in the array of applicants, which would be located at applicants.applicants.
I am not able to flatten the data in this case, the list of applicants for each shift does have to be an array contained in an object.
I tried this:
var hasApplied = pathEq(['applicants', 'applicants'], 'db/User/12');
console.log(filter(hasApplied, shifts));
But I don't think that is quite right because applicants.applicants is an array, I feed like I need to be feeding it one more function to get into the array of applicants but I'm not sure what.