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:
@@ -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);
|
||||
@@ -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()),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user