Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import { RowComment } from "@toolctrl/db/prisma-browser";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { UserSimple } from "../users.db.server";
|
||||
import { RowCommentReactionWithDetails } from "./rowCommentReaction.db.server";
|
||||
import UserModelHelper from "~/utils/helpers/models/UserModelHelper";
|
||||
|
||||
export type RowCommentWithDetails = RowComment & {
|
||||
createdByUser: UserSimple;
|
||||
reactions: RowCommentReactionWithDetails[];
|
||||
// replies: (RowComment & { createdByUser: User })[];
|
||||
};
|
||||
|
||||
export async function getRowComments(rowId: string): Promise<RowCommentWithDetails[]> {
|
||||
return await db.rowComment.findMany({
|
||||
where: {
|
||||
rowId,
|
||||
// parentCommentId: null,
|
||||
},
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
reactions: {
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
},
|
||||
},
|
||||
// replies: {
|
||||
// include: {
|
||||
// ...UserModelHelper.includeSimpleCreatedByUser,
|
||||
// },
|
||||
// },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getRowComment(id: string): Promise<RowCommentWithDetails | null> {
|
||||
return await db.rowComment.findUnique({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
reactions: {
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
},
|
||||
},
|
||||
// replies: {
|
||||
// include: {
|
||||
// ...UserModelHelper.includeSimpleCreatedByUser,
|
||||
// },
|
||||
// },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getRowCommentInRow({ id, rowId }: { id: string; rowId: string }): Promise<RowCommentWithDetails | null> {
|
||||
return await db.rowComment.findFirst({
|
||||
where: {
|
||||
id,
|
||||
rowId,
|
||||
},
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
reactions: {
|
||||
include: {
|
||||
...UserModelHelper.includeSimpleCreatedByUser,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function createRowComment(data: { createdByUserId: string; rowId: string; value: string }) {
|
||||
return await db.rowComment.create({
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateRowCommentInRow({ id, rowId }: { id: string; rowId: string }, data: { value?: string; isDeleted?: boolean }) {
|
||||
const updated = await db.rowComment.updateMany({
|
||||
where: {
|
||||
id,
|
||||
rowId,
|
||||
},
|
||||
data,
|
||||
});
|
||||
if (updated.count !== 1) {
|
||||
throw new Error("Row comment not found");
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
Reference in new issue
Block a user