Child取得util実装

This commit is contained in:
ろむねこ 2024-06-19 16:03:11 +09:00
parent 8623d6311e
commit 47f689c3c6
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -1,4 +1,4 @@
import { User } from '@prisma/client';
import { Child, User } from '@prisma/client';
import prisma from '@src/prisma';
async function findUserById(userId: string): Promise<User> {
@ -14,4 +14,17 @@ async function findUserById(userId: string): Promise<User> {
});
}
export { findUserById };
async function findChildById(childId: string): Promise<Child> {
return await prisma.child.findUnique({
where: {
id: childId
}
}).then(child => {
if (!child) {
throw new Error('ユーザーが見つかりません');
}
return child;
});
}
export { findUserById, findChildById }