TBH I don’t completely understand what I have going on here (someone else set this up for me) but I want to be able to have it query an alternate backup database if this CurrentLocalCopy one is empty (as it sometimes is when refreshing it/clearing stuff out, or if something messes up). I want to make it so if it doesn’t return anything it will just switch to the other one (called Day2Backup). Is there a simple way to do this for someone who’s new to coding? Here’s the current code:
async function getProductData (category) {
const itemData = wixData.query('CurrentLocalCopy')
.eq('collectionName', category)
.descending('brandNo')
.limit(1000)
.find()
.then((results) => {return results.items})
.catch(console.error)
return itemData
}
If the CurrentLocalCopy data collection is empty I just want it to use the backup collection instead. Thanks!