Hi thanks for posting this. So I used your code with mine to count and display followers, however, I can’t seem to get it to work. I don’t have any errors, it just isn’t counting anything. I changed this code:
$w("#text12, #text12").text = "Followers " + num;
To this to see if it wasn’t displaying right:
$w("#text12, #text12").text = "Followers " + 1;
But that works fine. I think it might have something to do with this part of the code:
wixData.query("Followers") // < I know what this does, lol.
.eq("Title", "Count") // < I'm not sure about this part.
I don’t know really what this part does. ^
Would anyone be willing to help? I’d greatly appreciate it! This is my whole code:
import wixUsers from "wix-users";
import wixData from "wix-data";
export function button5_click(event, $w) {
wixData.query("Followers")
.eq("Title", "Count")
.count()
.then( (num) => {
let numberOfItems = num;
$w("#text12, #text12").text = "Followers " + num;
} )
const followersId = wixUsers.currentUser.id;
console.log("followersId: ", followersId);
const followeesId = $w("#dataset5").getCurrentItem()._owner;
console.log("followeesId: ", followeesId);
wixData.insert("Followers", {
"followees": followeesId,
"followers": followersId
}) .catch((err) => {
console.log(err);
});
}