18 lines
533 B
TypeScript
18 lines
533 B
TypeScript
import type { Prisma } from '../generated/prisma/client';
|
|
import { AppError } from '../common/errors/app-error';
|
|
export async function requireArticle(
|
|
tx: Prisma.TransactionClient,
|
|
organizationId: string,
|
|
id: string,
|
|
) {
|
|
const article = await tx.blogArticle.findFirst({
|
|
where: { id, organizationId },
|
|
});
|
|
if (!article) throw new AppError('BLOG_NOT_FOUND');
|
|
return article;
|
|
}
|
|
export function nextBlogVersion(version: number) {
|
|
if (version >= 2147483647) throw new AppError('BLOG_CHANGED');
|
|
return version + 1;
|
|
}
|