refactor: remove unused file, update timestamps on query views and views

- Deleted the unused file `src/auth/drizzle/one.ts`.
- Modified `updatedAt` field in `src/db/drizzle/schema.ts` to automatically update on record changes.
- Added `updatedAt` field to the response in `src/routes/query-views/list.ts` and `src/routes/views/list.ts` to ensure it reflects the current timestamp.
This commit is contained in:
2026-03-05 13:32:56 +08:00
parent 2518f6bba3
commit 42957af179
6 changed files with 310 additions and 143 deletions

View File

@@ -1,10 +0,0 @@
import { drizzle } from 'drizzle-orm/node-postgres';
import { users } from './user.ts';
import dotenv from 'dotenv';
dotenv.config();
const db = drizzle(process.env.DATABASE_URL!);
const one = await db.select().from(users).limit(1);
console.log(one);

View File

@@ -477,7 +477,7 @@ export const queryViews = pgTable("query_views", {
data: jsonb().default({}),
createdAt: timestamp('createdAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
updatedAt: timestamp('updatedAt').notNull().defaultNow().$onUpdate(() => new Date()),
}, (table) => [
index('query_views_uid_idx').using('btree', table.uid.asc().nullsLast()),
index('query_title_idx').using('btree', table.title.asc().nullsLast()),

View File

@@ -88,6 +88,7 @@ app.route({
tags: rest.tags,
link: rest.link,
data: rest.data,
updatedAt: new Date()
}).where(eq(schema.queryViews.id, id)).returning();
}
ctx.body = view;

View File

@@ -91,6 +91,7 @@ app.route({
link: rest.link,
data: rest.data,
views: rest.views,
updatedAt: new Date()
}).where(eq(schema.routerViews.id, id)).returning();
}
ctx.body = view;