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 { toBookChapterSchema } from './mappers/bookChapterMapper';
export async function BookChapterManyResolver(
_: any,
{ input }: QueryBookChapterManyArgs,
{ identity }: IdentityContext
{ req, res, identity }: IdentityContext
): Promise<BookChapterManyOutput> {
const { bookId, filter } = input;
const terms = filter.terms?.toLowerCase();
@ -19,11 +19,14 @@ export async function BookChapterManyResolver(
const items = await prisma.bookChapter.findMany({
where: bookChapterWhere,
skip: filter.offset ?? 0,
take: filter.size ?? 10
take: filter.size ?? 10,
orderBy: { sequenceNumber: 'asc' }
});
return {
items: await Promise.all(items.map(value => toBookChapterSchema(value))),
items: await Promise.all(
items.map(value => toBookChapterSchema(value, { req, res, identity }))
),
total: items.length
};
}