I am using the following to code to query my member profiles to use the phone of the logged in member to filter entries in another dataset. It works great as long as there is a phone number in there, if not it gets a undefined result and ignores the .eq in the second query.
$w.onReady(function () {
var user = wixUsers.currentUser;
var userId = user.id;
var isLoggedIn = user.loggedIn;
user.getEmail()
.then((email) => {
let userEmail = email;
wixData.query("Members/PrivateMembersData")
.eq("loginEmail", userEmail)
.find()
.then((results) => {
let items = results.items;
let phone = items[0].mainPhone;
console.log(items);
console.log(phone);
wixData.query("stallSales")
.eq("trainerCellPhone", phone)
.find()
.then(results => {
console.log(results.totalCount)
let resultItems = results.items;
const showList = resultItems.map(item => item.horseShowId);
console.log(resultItems)
console.log(showList)
$w("#group1").expand();
$w('#dataset2').setFilter(wixData.filter()
.hasSome("horseShowId", showList)
)
})
})
})
})