This commit is contained in:
metacryst
2026-04-28 20:05:00 -05:00
commit 0d6c7683ff
123 changed files with 20922 additions and 0 deletions

47
tasks/server/functions.js Normal file
View File

@@ -0,0 +1,47 @@
export async function getTasks(networkId) {
const tasks = await this.sql`
SELECT * FROM tasks.tasks
WHERE network_id = ${networkId}
AND is_active = true
ORDER BY created ASC
`;
return tasks
}
export async function addTask(networkId, title) {
const [task] = await this.sql`
INSERT INTO tasks.tasks (title, network_id)
VALUES (${title}, ${networkId})
RETURNING *
`;
return task
}
export async function updateTaskDone(taskId, done) {
const [task] = await this.sql`
UPDATE tasks.tasks
SET done = ${done}
WHERE id = ${taskId}
RETURNING *
`;
return task
}
export async function editTaskTitle(taskId, title) {
const [task] = await this.sql`
UPDATE tasks.tasks
SET title = ${title}
WHERE id = ${taskId}
RETURNING *
`;
return task
}
export async function deleteTask(taskId) {
await this.sql`
UPDATE tasks.tasks
SET is_active = false
WHERE id = ${taskId}
`;
return { ok: true }
}