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.