len
November 2, 2021, 8:33pm
1
I have a simple function that always works fine in PREVIEW but it never shows results in LIVE. What am I missing?
Data.jsw code
export async function getCommissions() {
try {
let mySQL = 'SELECT Agent.commissionsDisplayName, Agent.displayName, Commissions._id, '
mySQL += 'Commissions.date, Commissions.payeeEmail, Agent.email, Commissions.policy, '
mySQL += 'Commissions.clientFirstName, Commissions.clientLastName, Commissions.type, Commissions.amount '
mySQL += 'FROM Commissions '
mySQL += 'INNER JOIN Agent ON Commissions.payeeEmail = Agent.email '
const results = await sql(mySQL);
return results.payload.data.rows;
}
catch (error) {
console.error(error);
}
}
Page Code:
async function doSearch()
{
let myResults = await getCommissions()
$w(“#tableResults ”).rows = myResults;
}
Check DATABASE + BACKEND-PERMISSIONS first.
Set them to lowest level to ensure, that this is not the missing point.
len
November 2, 2021, 9:05pm
3
Thanks, tried that but no good. It all works properly using wixData… I am converting (well, trying to convert) wixData over to SQL. So the issue is with the SQL implementation.
Maybe it will be easier to learn how to do inner joins with WixData? Can’t say I really have a clue… SQL is easy and I have done it for years.
What exactly do you mean by…
Maybe it will be easier to learn how to do inner joins with WixData?
What do you want to → “join” exactly?
Perhaps a little example?
len
November 2, 2021, 10:29pm
5
Look at my SQL. I would not know how to do something similar with wixData. I need to join data from 2 tables/collections. Thank you!
let mySQL = 'SELECT Agent.commissionsDisplayName, Agent.displayName, Commissions._id, '
mySQL += 'Commissions.date, Commissions.payeeEmail, Agent.email, Commissions.policy, '
mySQL += 'Commissions.clientFirstName, Commissions.clientLastName, Commissions.type, Commissions.amount '
mySQL += 'FROM Commissions '
mySQL += 'INNER JOIN Agent ON Commissions.payeeEmail = Agent.email
Here some more info for you…