wip create modal
This commit is contained in:
@@ -2,7 +2,7 @@ import { sqliteTable, int, text } from 'drizzle-orm/sqlite-core'
|
||||
|
||||
export const event = sqliteTable('event', {
|
||||
id: int().primaryKey({ autoIncrement: true }),
|
||||
userid: text().notNull(),
|
||||
userid: text().notNull(),
|
||||
title: text().notNull(),
|
||||
description: text().notNull(),
|
||||
from: text().notNull(),
|
||||
@@ -12,13 +12,13 @@ export const event = sqliteTable('event', {
|
||||
})
|
||||
|
||||
export const task = sqliteTable('task', {
|
||||
id: int().primaryKey({ autoIncrement: true }),
|
||||
userid: text().notNull(),
|
||||
id: int().primaryKey({ autoIncrement: true }),
|
||||
userid: text().notNull(),
|
||||
title: text().notNull(),
|
||||
description: text().notNull(),
|
||||
done: int().notNull(),
|
||||
estimated_time: int().notNull(),
|
||||
due_date: text().notNull(),
|
||||
done: int().notNull(),
|
||||
estimated_time: int().notNull(),
|
||||
due_date: text(),
|
||||
created_at: text().notNull().default(new Date().toISOString()),
|
||||
updated_at: text().notNull().default(new Date().toISOString())
|
||||
})
|
||||
|
||||
@@ -23,6 +23,7 @@ app.get('/', (req, res) => {
|
||||
|
||||
app.get('/tasks', async (req, res) => {
|
||||
const tasks: typeof task.$inferSelect[] = await db.select().from(task)
|
||||
console.log(tasks)
|
||||
res.status(200).send(tasks.map<TaskResponse>(task => {
|
||||
return { ...task, done: task.done === 1 }
|
||||
}));
|
||||
@@ -78,6 +79,7 @@ app.post('/task', async(req, res) => {
|
||||
const newTask = req.body
|
||||
newTask.userid = userId
|
||||
|
||||
console.log(newTask)
|
||||
const returnedTask = await db.insert(task).values(newTask).returning()
|
||||
console.log(returnedTask)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user