I am using a simple count query to get the number of items in database. I am then displaying that info as text on a page. Is there a way to auto refresh the count query without having to refresh the entire page? I am trying to make the number "live", so like a refresh state of like 1-5 mins if possible. Here is the code i am working with.
import wixData from 'wix-data';
import {session} from 'wix-storage';
$w.onReady(function () { getCounts(); }); // Get count of new referrals function getCounts() { wixData.query("Referrals") //my collection name .count() .then( (num) => { let numberOfItems = num; $w("#referralCount").text = "0" + num; //works } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } ); // Get count of new plan change requests wixData.query("PlanChangeRequest") //my collection name .count() .then( (num) => { let numberOfItems = num; $w("#subChangecount").text = "0" + num; //works } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } ); // Get count of cancel service surveys wixData.query("CancelService") //my collection name .count() .then( (num) => { let numberOfItems = num; $w("#cancel").text = "0" + num; // working } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } ); // Get count of cancel service surveys wixData.query("Register") //my collection name .count() .then( (num) => { let numberOfItems = num; $w("#users").text = "0" + num; // working } ) .catch( (error) => { let errorMsg = error.message; let code = error.code; } ); }