mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-09 20:30:54 -05:00
30 lines
487 B
TypeScript
30 lines
487 B
TypeScript
import { db } from "~/utils/db.server";
|
|
|
|
export function create({
|
|
content,
|
|
roomId,
|
|
userId,
|
|
}: {
|
|
content: string;
|
|
roomId: string;
|
|
userId: string;
|
|
}) {
|
|
return db.chatMessage.create({
|
|
data: {
|
|
content,
|
|
roomId,
|
|
senderId: userId,
|
|
},
|
|
});
|
|
}
|
|
|
|
export function findByRoomIds(roomIds: string[]) {
|
|
return db.chatMessage.findMany({
|
|
where: { roomId: { in: roomIds } },
|
|
orderBy: { createdAt: "asc" },
|
|
include: {
|
|
sender: true,
|
|
},
|
|
});
|
|
}
|