All rows from dataset is getting displayed even though I have code to show only few rows using my code. I like to show data only applicable to logged user from a dataset using: wixData.query(“members”).eq(“memberId”, wixUsers.currentUser.id)..)
I see code running fine with no error/exception. But all rows from the dataset is getting displayed in the table.
How do I fix it? Thanks
Code:
import wixData from ‘wix-data’;
import wixUsers from ‘wix-users’;
import wixLocation from’wix-location’;
let rowIndex = 0;
let rowData =0;
$w.onReady(function () {
console.log(“Load Table”);
let firstItem;
wixData.query(“members”).eq(“memberId”, wixUsers.currentUser.id)
.find()
.then( (results) => {
let items = results.items;
let totalCount = results.totalCount;
let rows = $w("#table1").rows;
let tabInd = 0;
let lstNm = "";
for (var i = 0; i < totalCount; i++) {
firstItem = items[i];
console.log(firstItem['memberId'] + ' == ' + wixUsers.currentUser.id + " - " + firstItem['firstName'])
if (tabInd < rows.length){
if(firstItem['title'] !== null && firstItem['title'] !== '')
{
rows[tabInd]["name"] = firstItem['title'];
$w("#lstNmText").text = "Family Lastname: " + firstItem['title'];
lstNm = firstItem['title']
}
if(firstItem['title'] !== null && firstItem['title'] !== '' && firstItem['title'] !== lstNm)
{
rows[tabInd]["name"] = firstItem['firstName'] + " " + firstItem['title'] ;
}
else{
rows[tabInd]["name"] = firstItem['firstName'];
}
rows[tabInd]["nakshthra"] = firstItem['nakshthra'];
rows[tabInd]["rasi"] = firstItem['rasi'];
if(firstItem['gothra'] !== null && firstItem['gothra'] !== '' && firstItem['gothra'] !== undefined)
{
$w("#gothraTxt").text = "Family Gothra: " + firstItem['gothra'];
$w('#Gothra').text = "Add new member";
$w('#gotInp').hide();
}
tabInd++;
}
}
$w("#table1").rows = rows;
$w("#table1").show('FadeIn');
console.log("Done with load method");
} )
.catch( (err) => {
console.error(err);
} );
});