Feat/um 62 prisma property names (#1562)

* checkpoint

* fix pg schema

* fix mysql schema

* change property names
This commit is contained in:
Brian Cao 2022-10-10 13:42:18 -07:00 committed by GitHub
parent 36edbe2f4c
commit 78338205a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 431 additions and 433 deletions

View file

@ -1,40 +1,40 @@
import prisma from 'lib/prisma';
import redis, { DELETED } from 'lib/redis';
export async function deleteAccount(user_id) {
export async function deleteAccount(userId) {
const { client } = prisma;
const websites = await client.website.findMany({
where: { user_id },
select: { website_uuid: true },
where: { userId },
select: { websiteUuid: true },
});
let websiteUuids = [];
if (websites.length > 0) {
websiteUuids = websites.map(a => a.website_uuid);
websiteUuids = websites.map(a => a.websiteUuid);
}
return client
.$transaction([
client.pageview.deleteMany({
where: { session: { website: { user_id } } },
where: { session: { website: { userId } } },
}),
client.event_data.deleteMany({
where: { event: { session: { website: { user_id } } } },
client.eventData.deleteMany({
where: { event: { session: { website: { userId } } } },
}),
client.event.deleteMany({
where: { session: { website: { user_id } } },
where: { session: { website: { userId } } },
}),
client.session.deleteMany({
where: { website: { user_id } },
where: { website: { userId } },
}),
client.website.deleteMany({
where: { user_id },
where: { userId },
}),
client.account.delete({
where: {
user_id,
id: userId,
},
}),
])

View file

@ -1,9 +1,9 @@
import prisma from 'lib/prisma';
export async function getAccountById(user_id) {
export async function getAccountById(userId) {
return prisma.client.account.findUnique({
where: {
user_id,
id: userId,
},
});
}

View file

@ -3,17 +3,17 @@ import prisma from 'lib/prisma';
export async function getAccounts() {
return prisma.client.account.findMany({
orderBy: [
{ is_admin: 'desc' },
{ isAdmin: 'desc' },
{
username: 'asc',
},
],
select: {
user_id: true,
id: true,
username: true,
is_admin: true,
created_at: true,
updated_at: true,
isAdmin: true,
createdAt: true,
updatedAt: true,
},
});
}

View file

@ -1,9 +1,9 @@
import prisma from 'lib/prisma';
export async function updateAccount(user_id, data) {
export async function updateAccount(userId, data) {
return prisma.client.account.update({
where: {
user_id,
id: userId,
},
data,
});