From db2d346cd6c265d8e7c69383c6de03bf5f6252f0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 6 Oct 2024 12:26:31 +0000 Subject: refactor: Include userId in the assets table --- packages/trpc/routers/bookmarks.test.ts | 4 ++++ packages/trpc/routers/bookmarks.ts | 1 + 2 files changed, 5 insertions(+) (limited to 'packages/trpc/routers') diff --git a/packages/trpc/routers/bookmarks.test.ts b/packages/trpc/routers/bookmarks.test.ts index 9fcbec52..d6a7bc27 100644 --- a/packages/trpc/routers/bookmarks.test.ts +++ b/packages/trpc/routers/bookmarks.test.ts @@ -344,6 +344,7 @@ describe("Bookmark Routes", () => { test("mutate assets", async ({ apiCallers, db }) => { const api = apiCallers[0].bookmarks; + const userId = await apiCallers[0].users.whoami().then((u) => u.id); const bookmark = await api.createBookmark({ url: "https://google.com", @@ -354,16 +355,19 @@ describe("Bookmark Routes", () => { id: "asset1", assetType: AssetTypes.LINK_SCREENSHOT, bookmarkId: bookmark.id, + userId, }), db.insert(assets).values({ id: "asset2", assetType: AssetTypes.LINK_BANNER_IMAGE, bookmarkId: bookmark.id, + userId, }), db.insert(assets).values({ id: "asset3", assetType: AssetTypes.LINK_FULL_PAGE_ARCHIVE, bookmarkId: bookmark.id, + userId, }), ]); diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 895e072a..b1491a61 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -853,6 +853,7 @@ export const bookmarksAppRouter = router({ id: input.asset.id, assetType: mapSchemaAssetTypeToDB(input.asset.assetType), bookmarkId: input.bookmarkId, + userId: ctx.user.id, }) .returning(); return input.asset; -- cgit v1.2.3-70-g09d2