chore: cleanup and feedback implementation

This commit is contained in:
Catalin Pit
2023-12-08 13:28:34 +00:00
parent 54401b94ae
commit 66c0db91da
7 changed files with 90 additions and 56 deletions

View File

@ -6,7 +6,7 @@ export type DeleteTokenByIdOptions = {
};
export const deleteTokenById = async ({ id, userId }: DeleteTokenByIdOptions) => {
return prisma.apiToken.delete({
return await prisma.apiToken.delete({
where: {
id,
userId,

View File

@ -1,25 +0,0 @@
import { prisma } from '@documenso/prisma';
type GetDocumentsProps = {
page: number;
perPage: number;
userId: number;
};
export const getDocuments = async ({ page = 1, perPage = 10, userId }: GetDocumentsProps) => {
const [documents, count] = await Promise.all([
await prisma.document.findMany({
where: {
userId,
},
take: perPage,
skip: Math.max(page - 1, 0) * perPage,
}),
await prisma.document.count(),
]);
return {
documents,
totalPages: Math.ceil(count / perPage),
};
};