I have a javascript query that triggers multiple resource queries (mysql database). I noticed in testing that the javascript query does not automatically fail if one of the queries it triggers fails. How can i detect if one of the queries fails? My javascript query is below.
//call first insert statement and get LAST_INSERT_ID() from it
const trenching_query = await ft_sill_insert_trenching.trigger();
const trenching_id_value = trenching_query.trenching_id[0];
console.log(trenching_id_value);
if (!Number.isInteger(trenching_id_value ))
{
throw new Error("Error inserting data, contact IT");
}
const array = [...fileDropzone3.value, ...fileDropzone4.value]
//call insert query for each picture uploaded
const promises = array.map((item) => {
return ft_sill_trench_insert_photos.trigger({
additionalScope: {
trenching_id_scope: trenching_id_value,
binary_data: atob(item.base64Data)
}
});
});
try{
await Promise.all(promises);
}catch {
throw new Error("Error inserting data, contact IT");
}
Being that retool doesn't allow transactions across multiple queries I need a way to undo a query if the child table inserts fail. Any help would be appreciated.