From 0addc7bc329671460509d39a841293a321971584 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 13 Jul 2025 21:08:08 +0000 Subject: Revert "fix: Fix the types of the bookmark types in the db query" This reverts commit 4ba3e8047a5b1f160169617187436c09e91662ec. --- packages/db/schema.ts | 15 ++++++++++++--- packages/trpc/routers/bookmarks.ts | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'packages') diff --git a/packages/db/schema.ts b/packages/db/schema.ts index 540c4c82..6dacdec6 100644 --- a/packages/db/schema.ts +++ b/packages/db/schema.ts @@ -649,9 +649,18 @@ export const bookmarkRelations = relations(bookmarks, ({ many, one }) => ({ fields: [bookmarks.userId], references: [users.id], }), - link: one(bookmarkLinks), - text: one(bookmarkTexts), - asset: one(bookmarkAssets), + link: one(bookmarkLinks, { + fields: [bookmarks.id], + references: [bookmarkLinks.id], + }), + text: one(bookmarkTexts, { + fields: [bookmarks.id], + references: [bookmarkTexts.id], + }), + asset: one(bookmarkAssets, { + fields: [bookmarks.id], + references: [bookmarkAssets.id], + }), tagsOnBookmarks: many(tagsOnBookmarks), bookmarksInLists: many(bookmarksInLists), assets: many(assets), diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index ef6ce396..9aa9ec1e 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -187,7 +187,7 @@ async function toZodSchema( let content: ZBookmarkContent = { type: BookmarkTypes.UNKNOWN, }; - if (link) { + if (bookmark.link) { content = { type: BookmarkTypes.LINK, screenshotAssetId: assets.find( @@ -219,7 +219,7 @@ async function toZodSchema( dateModified: link.dateModified, }; } - if (text) { + if (bookmark.text) { content = { type: BookmarkTypes.TEXT, // It's ok to include the text content as it's usually not big and is used to render the text bookmark card. @@ -227,7 +227,7 @@ async function toZodSchema( sourceUrl: text.sourceUrl, }; } - if (asset) { + if (bookmark.asset) { content = { type: BookmarkTypes.ASSET, assetType: asset.assetType, -- cgit v1.2.3-70-g09d2