Another query for something probably obvious I'm doing in wrong!
I have a database which contains numerous records for various members. I would like to return and display a count of the number of records for the member (user) currently logged on. This is my code:
export function button6_click(event) { getCounts(); } function getCounts() { wixData.query("Properties") //my collection name // .eq("_id", wixUsers.currentUser.id) .count() .then( (num) => { let numberOfItems = num; var n = numberOfItems.toString(); $w('#text39').text = n; } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } ); }
Note that this version has the .eq("_id", wixUsers.currentUser.id) removed. This works find except (as expected) it returns a count of ALL records for ALL users.
However if I add the .eq("_id", wixUsers.currentUser.id) line of code back in, I always get a count of zero returned. There are entries in the database for this user.
What am I doing wrong?
Thanks in advance.
I am having problem with the count function, when ever am trying to use it, asynchronous or by calling it, it doesn't function, as i expect it to
$w.onReady(function () { $w("#ainaMradi").onChange((event) => { memory.removeItem("kazi"); $w("#kazitagTXT").text = memory.getItem("kazi"); $w("#kazitagTXT").hide().then(count); }); }); //************************************************format memory************ */ function count() { let count = $w("#dataset4").getTotalCount(); if (count > 0) { $w("#kaziallBox").expand(); $w("#texttext").text = count.toString(); } else { $w("#kaziallBox").collapse(); $w("#texttext").text = count.toString(); } }
can someone else help us?