Skip to content

Commit

Permalink
use conflictUpdateAllExcept
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Jan 17, 2025
1 parent 43e5c64 commit 6b59d64
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions apps/mobile/src/services/entry.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { eq, sql } from "drizzle-orm"
import { eq } from "drizzle-orm"

import { db } from "../database"
import { entriesTable } from "../database/schemas"
import type { EntrySchema } from "../database/schemas/types"
import { dbStoreMorph } from "../morph/db-store"
import { entryActions } from "../store/entry/store"
import type { Hydratable, Resetable } from "./internal/base"
import { conflictUpdateAllExcept } from "./internal/utils"

class EntryServiceStatic implements Hydratable, Resetable {
async reset() {
Expand All @@ -19,26 +20,7 @@ class EntryServiceStatic implements Hydratable, Resetable {
.values(entries)
.onConflictDoUpdate({
target: [entriesTable.id],
set: {
title: sql`excluded.title`,
url: sql`excluded.url`,
content: sql`excluded.content`,
description: sql`excluded.description`,
guid: sql`excluded.guid`,
author: sql`excluded.author`,
authorUrl: sql`excluded.author_url`,
authorAvatar: sql`excluded.author_avatar`,
insertedAt: sql`excluded.inserted_at`,
publishedAt: sql`excluded.published_at`,
media: sql`excluded.media`,
categories: sql`excluded.categories`,
attachments: sql`excluded.attachments`,
extra: sql`excluded.extra`,
language: sql`excluded.language`,
feedId: sql`excluded.feed_id`,
inboxHandle: sql`excluded.inbox_handle`,
read: sql`excluded.read`,
},
set: conflictUpdateAllExcept(entriesTable, ["id"]),
})
}

Expand Down

0 comments on commit 6b59d64

Please sign in to comment.