mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
join owners with ProjectsByOwnerID
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
import { Issue, Project, User } from "@issue/shared";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "../client";
|
import { db } from "../client";
|
||||||
import { Issue, Project, User } from "@issue/shared";
|
|
||||||
|
|
||||||
export async function createProject(blob: string, name: string, ownerId: number) {
|
export async function createProject(blob: string, name: string, ownerId: number) {
|
||||||
const [project] = await db
|
const [project] = await db
|
||||||
@@ -40,8 +40,12 @@ export async function getProjectByBlob(projectBlob: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getProjectsByOwnerID(ownerId: number) {
|
export async function getProjectsByOwnerID(ownerId: number) {
|
||||||
const projects = await db.select().from(Project).where(eq(Project.ownerId, ownerId));
|
const projectsWithOwners = await db
|
||||||
return projects;
|
.select()
|
||||||
|
.from(Project)
|
||||||
|
.where(eq(Project.ownerId, ownerId))
|
||||||
|
.leftJoin(User, eq(Project.ownerId, User.id));
|
||||||
|
return projectsWithOwners;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllProjects() {
|
export async function getAllProjects() {
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ function Index() {
|
|||||||
}
|
}
|
||||||
const project = projects.find((p) => p.Project.id === Number(value));
|
const project = projects.find((p) => p.Project.id === Number(value));
|
||||||
if (!project) {
|
if (!project) {
|
||||||
// TODO: toast here
|
|
||||||
console.error(`NO PROJECT FOUND FOR ID: ${value}`);
|
console.error(`NO PROJECT FOUND FOR ID: ${value}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -81,6 +80,7 @@ function Index() {
|
|||||||
{project.Project.name}
|
{project.Project.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))}
|
||||||
|
{/* {projects.length === 0 && <>No projects</>} */}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
{selectedProject && (
|
{selectedProject && (
|
||||||
|
|||||||
Reference in New Issue
Block a user