mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
added sprint db queries
This commit is contained in:
@@ -2,5 +2,6 @@ export * from "./issues";
|
|||||||
export * from "./organisations";
|
export * from "./organisations";
|
||||||
export * from "./projects";
|
export * from "./projects";
|
||||||
export * from "./sessions";
|
export * from "./sessions";
|
||||||
|
export * from "./sprints";
|
||||||
export * from "./timed-sessions";
|
export * from "./timed-sessions";
|
||||||
export * from "./users";
|
export * from "./users";
|
||||||
|
|||||||
27
packages/backend/src/db/queries/sprints.ts
Normal file
27
packages/backend/src/db/queries/sprints.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Sprint } from "@issue/shared";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import { db } from "../client";
|
||||||
|
|
||||||
|
export async function createSprint(
|
||||||
|
projectId: number,
|
||||||
|
name: string,
|
||||||
|
color: string | undefined,
|
||||||
|
startDate: Date,
|
||||||
|
endDate: Date,
|
||||||
|
) {
|
||||||
|
const [sprint] = await db
|
||||||
|
.insert(Sprint)
|
||||||
|
.values({
|
||||||
|
projectId,
|
||||||
|
name,
|
||||||
|
...(color ? { color } : {}),
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
})
|
||||||
|
.returning();
|
||||||
|
return sprint;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getSprintsByProject(projectId: number) {
|
||||||
|
return await db.select().from(Sprint).where(eq(Sprint.projectId, projectId));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user