added chapter view, fixes, added ratings, added chapter updates/deletions

This commit is contained in:
lnn0q 2025-06-01 00:37:26 +03:00
parent 029b7e9353
commit 4801cf3a13
34 changed files with 1345 additions and 191 deletions

View file

@ -7,7 +7,7 @@ import { toBookSchema } from './mappers/bookMapper';
export async function BookManyResolver(
_: any,
{ input }: QueryBookManyArgs,
{ identity }: IdentityContext
{ req, res, identity }: IdentityContext
): Promise<BookManyOutput> {
const { filter } = input;
const terms = filter.terms?.toLowerCase();
@ -20,11 +20,14 @@ export async function BookManyResolver(
const items = await prisma.book.findMany({
where: bookWhere,
skip: filter.offset ?? 0,
take: filter.size ?? 10
take: filter.size ?? 10,
orderBy: {
createdAt: 'desc'
}
});
return {
items: await Promise.all(items.map(value => toBookSchema(value))),
items: await Promise.all(items.map(value => toBookSchema(value, { req, res, identity }))),
total: await prisma.book.count({ where: bookWhere })
};
}