Handle website delete. Added response helper functions.

This commit is contained in:
Mike Cao 2020-08-07 17:19:42 -07:00
parent 0a411a9ad6
commit c4b75e4aec
31 changed files with 314 additions and 96 deletions

View file

@ -63,6 +63,21 @@ export async function getWebsites(user_id) {
);
}
export async function createWebsite(user_id, data) {
return runQuery(
prisma.website.create({
data: {
account: {
connect: {
user_id,
},
},
...data,
},
}),
);
}
export async function updateWebsite(website_id, data) {
return runQuery(
prisma.website.update({
@ -74,6 +89,19 @@ export async function updateWebsite(website_id, data) {
);
}
export async function deleteWebsite(website_id) {
return runQuery(
/* Prisma bug, does not cascade on non-nullable foreign keys
prisma.website.delete({
where: {
website_id,
},
}),
*/
prisma.queryRaw(`delete from website where website_id=$1`, website_id),
);
}
export async function createSession(website_id, data) {
return runQuery(
prisma.session.create({