I have a table swipe that I need to iterate through to fill an array that I can use to display a matches list to the user. The structure is the following (a valid match between two users):
Here is my raw logic to iterate through the table and get match objects that I will push into an array:
user = current_user_id;
for (swipes in swipe)
{
if (id_user === user)
{
to_match === id_user_matched;
for (swipes in swipe)
{
if (id_user === to_match && id_user_matched === user)
{
matches_list[].push({“id_match”: id_match, “id_user_matched”: to_match});
}
}
}
}
How can I do this in my backend with either an sql query or Node code?
Thank you!
