const users =
[
{
_id: "5fbfa729fc46a415ce5503a6",
first_name: 'Allen',
last_name: 'Border',
timestamp: 1606395689121,
key: [ "5fbf6f91aff7f3320a906547", "5fbfa748fc46a415ce5503a8" ]
},
{
_id: "5fbfa6fbfc46a415ce5503a4",
first_name: 'james',
last_name: 'roger',
timestamp: 1606395689125
},
{
_id: "5fbf6f91aff7f3320a906547",
first_name: 'david',
last_name: 'gosh',
timestamp: 1606395689130,
key: [ "5fbfa729fc46a415ce5503a6" ]
},
{
_id: "5e4e74eb380054797d9db623",
first_name: 'Ricky',
last_name: 'bichel',
timestamp: 1606395689131
}
]
const user_id = "5fbfa748fc46a415ce5503a8";
How can we categorize data as match or not match based on the provided user_id? The matched data should contain records where user_id matches with a value in users.key, while the not match data should contain records where there is no match. Is it possible to separate these two results?
This approach does not seem to be working properly.
const result = users.key.indexOf(user_id);
console.log(users.storyMute)