- Introduced support for nested comment replies in both frontend and backend. - Added comment liking and unliking features, including like count and "isLiked" state tracking. - Updated database schema with `parentId` and new `comment_likes` table. - Enhanced UI for threaded comments and implemented display of like counts and reply actions. - Refactored APIs and repositories to support replies, likes, and enriched comment data.
22 lines
584 B
TypeScript
22 lines
584 B
TypeScript
import { pgTable, primaryKey, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
import { comments } from "./comments";
|
|
import { users } from "./users";
|
|
|
|
export const commentLikes = pgTable(
|
|
"comment_likes",
|
|
{
|
|
commentId: uuid("comment_id")
|
|
.notNull()
|
|
.references(() => comments.id, { onDelete: "cascade" }),
|
|
userId: uuid("user_id")
|
|
.notNull()
|
|
.references(() => users.uuid, { onDelete: "cascade" }),
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
},
|
|
(t) => ({
|
|
pk: primaryKey({ columns: [t.commentId, t.userId] }),
|
|
}),
|
|
);
|