Showing
2 changed files
with
31 additions
and
0 deletions
| 1 | +import { prisma } from "../../../utils"; | ||
| 2 | + | ||
| 3 | +export default { | ||
| 4 | + Query: { | ||
| 5 | + seeAllMessage: async (_, args) => { | ||
| 6 | + const { roomId } = args; | ||
| 7 | + let room, messageList; | ||
| 8 | + try { | ||
| 9 | + room = await prisma.room.findOne({ | ||
| 10 | + where: { | ||
| 11 | + id: roomId, | ||
| 12 | + }, | ||
| 13 | + }); | ||
| 14 | + | ||
| 15 | + if (room !== undefined) { | ||
| 16 | + messageList = await prisma.message.findMany({ | ||
| 17 | + where: { | ||
| 18 | + roomId: roomId, | ||
| 19 | + }, | ||
| 20 | + }); | ||
| 21 | + } | ||
| 22 | + } catch (e) { | ||
| 23 | + console.log(e); | ||
| 24 | + } | ||
| 25 | + return messageList; | ||
| 26 | + }, | ||
| 27 | + }, | ||
| 28 | +}; |
-
Please register or login to post a comment