feat: add topics to tasks
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
import { db } from "$lib/db"
|
||||
import { tasksToTopics } from "$lib/db/schema"
|
||||
|
||||
export const load = async () => {
|
||||
return {
|
||||
task: (await db.query.tasks.findFirst({
|
||||
with: {
|
||||
tasksToTopics: true
|
||||
tasksToTopics: {
|
||||
with: {
|
||||
topic: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
),
|
||||
topics: await db.query.topics.findMany()
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
addTopic: async ({ request, params }) => {
|
||||
const data = await request.formData()
|
||||
|
||||
const task = await db.insert(tasksToTopics).values({ taskId: params.id, topicId: data.get('topic-id') }).returning()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user