kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
at main 42 lines 1.0 kB view raw
1import db from "../../database"; 2import { columnTable, projectTable } from "../../database/schema"; 3 4const DEFAULT_COLUMNS = [ 5 { name: "To Do", slug: "to-do", position: 0, isFinal: false }, 6 { name: "In Progress", slug: "in-progress", position: 1, isFinal: false }, 7 { name: "In Review", slug: "in-review", position: 2, isFinal: false }, 8 { name: "Done", slug: "done", position: 3, isFinal: true }, 9]; 10 11async function createProject( 12 workspaceId: string, 13 name: string, 14 icon: string, 15 slug: string, 16) { 17 const [createdProject] = await db 18 .insert(projectTable) 19 .values({ 20 workspaceId, 21 name, 22 icon, 23 slug, 24 }) 25 .returning(); 26 27 if (createdProject) { 28 for (const col of DEFAULT_COLUMNS) { 29 await db.insert(columnTable).values({ 30 projectId: createdProject.id, 31 name: col.name, 32 slug: col.slug, 33 position: col.position, 34 isFinal: col.isFinal, 35 }); 36 } 37 } 38 39 return createdProject; 40} 41 42export default createProject;