mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
fix(backend): set updatedAt explicitly in all mutations
onConflictDoUpdate bypasses Drizzle's $onUpdate hook. Set updatedAt explicitly in all mutation methods. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -30,7 +30,7 @@ export function sources(db: Database, userId: string) {
|
|||||||
async enableSource(sourceId: string) {
|
async enableSource(sourceId: string) {
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.update(userSources)
|
.update(userSources)
|
||||||
.set({ enabled: true })
|
.set({ enabled: true, updatedAt: new Date() })
|
||||||
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
||||||
.returning({ id: userSources.id })
|
.returning({ id: userSources.id })
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ export function sources(db: Database, userId: string) {
|
|||||||
async disableSource(sourceId: string) {
|
async disableSource(sourceId: string) {
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.update(userSources)
|
.update(userSources)
|
||||||
.set({ enabled: false })
|
.set({ enabled: false, updatedAt: new Date() })
|
||||||
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
||||||
.returning({ id: userSources.id })
|
.returning({ id: userSources.id })
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export function sources(db: Database, userId: string) {
|
|||||||
.values({ userId, sourceId, config })
|
.values({ userId, sourceId, config })
|
||||||
.onConflictDoUpdate({
|
.onConflictDoUpdate({
|
||||||
target: [userSources.userId, userSources.sourceId],
|
target: [userSources.userId, userSources.sourceId],
|
||||||
set: { config },
|
set: { config, updatedAt: new Date() },
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export function sources(db: Database, userId: string) {
|
|||||||
async updateCredentials(sourceId: string, credentials: Buffer) {
|
async updateCredentials(sourceId: string, credentials: Buffer) {
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.update(userSources)
|
.update(userSources)
|
||||||
.set({ credentials })
|
.set({ credentials, updatedAt: new Date() })
|
||||||
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
.where(and(eq(userSources.userId, userId), eq(userSources.sourceId, sourceId)))
|
||||||
.returning({ id: userSources.id })
|
.returning({ id: userSources.id })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user