diff options
Diffstat (limited to 'packages/trpc')
| -rw-r--r-- | packages/trpc/routers/tags.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/trpc/routers/tags.ts b/packages/trpc/routers/tags.ts index 211c3633..f6ce752d 100644 --- a/packages/trpc/routers/tags.ts +++ b/packages/trpc/routers/tags.ts @@ -104,6 +104,32 @@ export const tagsAppRouter = router({ bookmarks: res.flatMap((t) => (t.bookmarkId ? [t.bookmarkId] : [])), }; }), + delete: authedProcedure + .input( + z + .object({ + tagId: z.string(), + }) + .or( + z.object({ + tagName: z.string(), + }), + ), + ) + .use(ensureTagOwnership) + .mutation(async ({ input, ctx }) => { + const res = await ctx.db + .delete(bookmarkTags) + .where( + and( + conditionFromInput(input, ctx.user.id), + eq(bookmarkTags.userId, ctx.user.id), + ), + ); + if (res.changes == 0) { + throw new TRPCError({ code: "NOT_FOUND" }); + } + }), list: authedProcedure .output( z.object({ |
