Was wondering if anyone could possibly tell me a work around for this not counting properly.
About 4 out of 5 times, this data query inside my hook returns the correct value. But sometimes it appears to not be counting the additional entry that set the hook off itself. About 1 out of 5 times it counts one less than the actual number of results it should be finding. Should I not be using a query in a hook? It seems like sometimes the hook is starting before the owner field is finished being filled in on the inserted item or something. Is there a better way to handle a count inside of a hook? There are no errors, it always gives me a count, it’s just not always right (if I get the wrong count, it’s always 1 less than it should have been)
export function UserSubmitsLand_afterInsert(item, context) {
let hookContext = context;
let memberEntry = item._owner
var submitted
wixData.query(“UserSubmitsLand”).eq(“_owner”, memberEntry).count()
.then((num) => {
console.log(“initial query found " + num + " results”);
…(rest of script which works fine)