Filter dataset from another dataset filtered through code

Hello! I am still new to corvid coding. I wanted to show extra information from the user when logged in so I created a secondary member/users database ( # dataset1). I filtered it with this code so it extracts the email from the logged in user so I can show other info such as “college”.

import wixUsers from ‘wix-users’ ;
import wixData from ‘wix-data’ ;

$w.onReady( async function () {
let userEmail = await wixUsers.currentUser.getEmail()
$w( “#dataset1” ).onReady(() => {
$w( “#dataset1” ).setFilter(wixData.filter()
.eq( “email” , userEmail)
)
});
});

But now I want to show a list of courses on a repeater from the college that the user belongs. For that I would need to filter the courses dataset from the college picked from the secondary member/users dataset (already filtered through code).

I really hope you can help me with the code so I can complete this. I have poor experience in corvid. Thank you so much for your time

Perhaps you should give a little bit more informations.
Do you use dynamic pages?

Show also the headlines and the first data-row of each DATABASES which are involved into your issue. All involved columns & headlines should be visible. And the involved DATABASE-names & DATASET-IDs should also be mentioned.

Ok, I will try to explain. So, the fist part is fine. What I need is to filter a dynamic page with repeaters.

There are two databases (apart from the main wix´s user database)

  1. Secondary users database (Name, Surnames, Age, College, Email)
  2. Courses (College, CourseName, Description, Duration)

So, in order to filter the courses dynamic page, that first part of the code I think is already done. It first filters the Secondary users dataset based on the logged in user email (which is the common row with the wix´s users database). With this I have the users name, surnames, age, college, etc.

Now I would need to search the college in that already filtered dataset. With that I can filter the courses dataset with the college row and it would only show the courses from the user´s college.

Perhaps something like this?

import wixData from 'wix-data';

function xxx (parameter) {
     wixData.query("Courses")
     .contains("college", "VALUE") // VALUE = result of filter-1
     .find()
    .then( (results) => {
 if(results.items.length > 0) {
 let firstItem = results.items[0]; 
               console.log(results)
        } else {    }
    } )
    .catch( (err) => {
 let errorMsg = err;
    } );
}

You can also use another filter-function like —> .eq() or .hasSome() and so on!