I have one array and one object:
const currentData = [{first: 'Breanna', last: 'Bazadoo', uid: '-Lz8YxHiwp8QZW3TqAFn'},
{first: 'Foo', last: 'Bazado', uid: '-Lz8YxHqQXWoaGOFRLrO'},
{first: 'Foo2', last: 'Bazado', uid: '-Lz8YxHsMItaaTVNyQRE'},
{first: 'Foo3', last: 'Bazado', uid: '-Lz8YxHy0S-QkDaE1PkX'}
];
const ministryMembers = { -MmFNu4jQ8A4_Aig0vdn: "-MmFNu4jQ8A4_Aig0vdn",
-Mxg8xKwZleW4J8yfzna: "-Lz8YxHqQXWoaGOFRLrO",
-Mxg9AxhUR6ZArBATw1M: "-Lz8YxHsMItaaTVNyQRE",
-Mxg9ECyBsj01zMqPE8s: "-MmFNgjyopU3E8z5g-zU",
-Mxg9GvmPFabK_185IOr: "-Lz8YxLVi_uZp_RkcRIH",
-Mxg9JbJ2sxgWLxk1tfx: "-MuEgimJOIbPw3GyKBJ3",
-Mxg9MZTKzlUD0lg07C0: "-Lz8YxHy0S-QkDaE1PkX",
-Mxg9Pnfmv7P3BQvINQV: "-Lz8YxJ-_wuk8bmEyvGT",
-Mxg9SB2vlOopJYtmG-Z: "-Lz8YxKj5WXY1oNwylQ4",
-Mxg9VrZFDNawvcWIgul: "-Lz8YxN87U1YM6_fKgq1" }
if currentData's uid is found in allMembers value in example currentData uid == allMembers value, I want to return the entire object from currentData and build the array again. There will be a lot more in currentData this is just an example.
I have done this:
const filteredData = Object.keys(ministryMembers).filter( m => currentData.find( cd => cd.uid == ministryMembers[m] ) );
console.log(filteredData);
It returns only the key. How can I get it to return the whole object? My other option was map the data and then return the whole object that way but I thought that there might be a more efficent way of doing it. Any thoughts?
allMembers, isuidkeyorvalue? and what isministryMembers?