Good catch! (pun intended).
For the record, if you’re using async/await in your code, you don’t need to use .then() and .catch(), as it can be written a little cleaner, in my opinion, using await without the then callback. For example, the above code block could look like:
try{
const queryResult = await wixData.query("Pairings")
.eq("pod", gameData.pod)
.eq("playerID", gameData.player)
.eq("opponentID", gameData.opponent)
.or(myQuery)
.find();
if (queryResult.items.length <= 0) { //I think we can replace this with query.get instead of .find > check this later
errorMessage("Error QP001: There appears to be a problem with the data that was submitted, please contact the system administrator as this error should not happen.");
record.error = true;
} else {
record.dbRecord = queryResult.items[0];
record.submittedRecord = checkExistingScore(gameData,record.dbRecord,status);
if (record.submittedRecord.error) {
errorMessage(record.submittedrecord.error);
record.error = true;
}
}
catch(err){
errorMessage("Critical Error QP002: Pairing data does not exist. Contact the administrator as this should not happen.",err);
}