mirror of
https://github.com/r-ca/kidshift-be.git
synced 2024-10-26 00:24:02 +00:00
Child取得util実装
This commit is contained in:
parent
8623d6311e
commit
47f689c3c6
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue
Block a user