mirror of
https://github.com/makeplane/plane.git
synced 2026-02-24 20:20:49 +01:00
feat: added projectLabel schema and service function
This commit is contained in:
@@ -105,6 +105,32 @@ export const projectMembers = pgTable("project_members", {
|
||||
isActive: boolean("is_active"),
|
||||
});
|
||||
|
||||
export const projectLabels = pgTable("labels", {
|
||||
id: uuid("id").primaryKey(),
|
||||
name: text("name"),
|
||||
description: text("description"),
|
||||
projectId: uuid("project_id"),
|
||||
workspaceId: uuid("workspace_id"),
|
||||
parentId: uuid("parent_id"),
|
||||
color: text("color"),
|
||||
sortOrder: integer("sort_order"),
|
||||
});
|
||||
|
||||
export const projectlabelsRelations = relations(projectLabels, ({ one }) => ({
|
||||
project: one(projects, {
|
||||
fields: [projectLabels.projectId],
|
||||
references: [projects.id],
|
||||
}),
|
||||
workspace: one(workspaces, {
|
||||
fields: [projectLabels.workspaceId],
|
||||
references: [workspaces.id],
|
||||
}),
|
||||
parent: one(projectLabels, {
|
||||
fields: [projectLabels.parentId],
|
||||
references: [projectLabels.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const projectMembersRelations = relations(projectMembers, ({ one }) => ({
|
||||
project: one(projects, {
|
||||
fields: [projectMembers.projectId],
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { eq, sql } from "drizzle-orm";
|
||||
import { DatabaseSingleton } from "../db/singleton";
|
||||
import { projectMembers, projects, states } from "../db/slack.schema";
|
||||
import {
|
||||
projectLabels,
|
||||
projectMembers,
|
||||
projects,
|
||||
states,
|
||||
} from "../db/slack.schema";
|
||||
|
||||
export class ProjectService {
|
||||
async getProjectsForWorkspace(workspaceId: string) {
|
||||
@@ -49,4 +54,22 @@ export class ProjectService {
|
||||
throw new Error("Database not found");
|
||||
}
|
||||
}
|
||||
|
||||
async getProjectLabels(projectId: string) {
|
||||
const db = DatabaseSingleton.getInstance().db;
|
||||
|
||||
if (!db) {
|
||||
throw new Error("Database not found");
|
||||
}
|
||||
|
||||
try {
|
||||
const labels = await db.query.projectLabels.findMany({
|
||||
where: eq(projectLabels.projectId, projectId),
|
||||
});
|
||||
|
||||
return labels;
|
||||
} catch (error) {
|
||||
throw new Error("Database not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user