Hi, I am needing assistance in finding a Query issue. My initial query is in the backend as I need it to bypass permissions. It has been working (at least so I thought). I added a record with missing fields, but I thought my .isNotEmpty() function would filter it out, but it has not. Now my repeater displays a record that has blank fields.
My backend JSW code:
import wixData from 'wix-data';
export function bypassMemberPerm() {
let options = {
"suppressAuth": true,
}
console.log(options);
console.log("Supp1");
return wixData.query("Players")
.include("region", "position")
.isNotEmpty("position")
.isNotEmpty("region")
.isNotEmpty("dateOfBirth")
.isNotEmpty("footballClub")
.isNotEmpty("preferredFoot")
.limit(1000)
.find(options)
.then((results) => {
if(results.totalCount>0){
return results.items;
}
else{
return "NORESULTS";
}
})
.catch((err) => {
let errorMsg = err;
});
}
In my front end, I call this method which is pulling records that are empty. Could someone assist in finding the flaw in my code?
Thanks in advance.
Why did your filter not work?
When you take a look onto your filtered query, how does your query work exactly?
I’m not sure. I’m trying to find that out here.
So in the meantime what I learn was that, on initial loading of the page, the repeater includes a record with missing fields (Empty fields). But when I “Filter” and then cancel the filter (Clear filter), the record that is empty is no longer there. So it is only an issue on initial loading of the page.
The code I posted above is the initial loading code.
The clear Button function has the following code:
export function clearSearchButton_click(event) {
$w('#searchInput').value = "";
$w('#positionDropdown').value = $w('#positionDropdown').placeholder;
$w('#regionDropdown').value = $w('#regionDropdown').placeholder;
$w('#preferredFootDropdown').value = $w('#preferredFootDropdown').placeholder;
$w(`#playerRepeater`).data = originalRows;
$w(`#playerRepeater`).onItemReady(($item, itemData, index) => {
console.log("Clear");
console.log(itemData);
$item(`#text48`).text = itemData.fullName;
$item('#image10').src = itemData.profileImage;
$item('#text51').text = itemData.dateOfBirth;
$item('#text52').text = itemData.position;
$item('#text53').text = itemData.region;
$item('#text59').text = itemData.preferredFoot;
$item('#text60').text = itemData.footballClub;
});
}
And this seems to work fine as it does not display the empty record!?
I seemed to have solved it with a bit of digging.
I needed to add the following:
$w(`#playerRepeater`).data = originalRows;
I added this line before the code that “sets” the repeater in my onReady() function. I had it already in my Clear function so it was working only when clearing.
Thanks for your time. Hopefully this helps the next person.
And as you can see, all you have needed is a question to solve your issue.
My guess to you would be to use more the → CONSOLE.
Using the console will give you more overview about your own working code. You will be able to genug your code faster and better.