Updated raw query method.

This commit is contained in:
Mike Cao 2021-12-16 21:33:53 -08:00
parent a609de0ea6
commit 5ce457efa5

View File

@ -36,7 +36,7 @@ export async function rawQuery(query, params = []) {
const sql = db === MYSQL ? query.replace(/\$[0-9]+/g, '?') : query; const sql = db === MYSQL ? query.replace(/\$[0-9]+/g, '?') : query;
return prisma.$queryRaw.apply(prisma, [sql, ...params]); return prisma.$queryRawUnsafe.apply(prisma, [sql, ...params]);
} }
export function getDateQuery(field, unit, timezone) { export function getDateQuery(field, unit, timezone) {
@ -170,14 +170,11 @@ export async function resetWebsite(website_id) {
export async function deleteWebsite(website_id) { export async function deleteWebsite(website_id) {
return runQuery( return runQuery(
/* Prisma bug, does not cascade on non-nullable foreign keys
prisma.website.delete({ prisma.website.delete({
where: { where: {
website_id, website_id,
}, },
}), }),
*/
prisma.$queryRaw`delete from website where website_id=${website_id}`,
); );
} }
@ -269,14 +266,11 @@ export async function updateAccount(user_id, data) {
export async function deleteAccount(user_id) { export async function deleteAccount(user_id) {
return runQuery( return runQuery(
/* Prisma bug, does not cascade on non-nullable foreign keys
prisma.account.delete({ prisma.account.delete({
where: { where: {
user_id, user_id,
}, },
}), }),
*/
prisma.$queryRaw`delete from account where user_id=${user_id}`,
); );
} }