Error on mutation `connection timeout error prisma.uRL.update()`

I'm building a url-shortner it just worked correctly until i added a redirect count trpc mutation before redirecting to the original url, it is giving connection timeout error on prisma.uRL.update() , idk why this is happening please help pages/[code].tsx
useEffect(() => {
(async () => {
if (typeof code === "string") {
const output = await trpcCtx.fetchQuery(["url.getLongURL", { code }]);
if (output.notFound) router.push("/notFound");
else {
await increaseRedirectCount.mutateAsync({
id: output.id,
redirects: output.redirects + 1,
});
router.push(output.longURL);
}
}
})();
});
useEffect(() => {
(async () => {
if (typeof code === "string") {
const output = await trpcCtx.fetchQuery(["url.getLongURL", { code }]);
if (output.notFound) router.push("/notFound");
else {
await increaseRedirectCount.mutateAsync({
id: output.id,
redirects: output.redirects + 1,
});
router.push(output.longURL);
}
}
})();
});
i also tried using trpc number update increment but it was giving the same error it redirects after a couple hundred mutations i'm using sqlite as the database for now my trpc mutation
.mutation("increaseRedirectCount", {
input: z.object({ id: z.string().cuid(), redirects: z.number() }),
async resolve({ ctx, input }) {
return await ctx.prisma.uRL.update({
where: { id: input.id },
data: {
redirects: input.redirects,
},
});
},
});
.mutation("increaseRedirectCount", {
input: z.object({ id: z.string().cuid(), redirects: z.number() }),
async resolve({ ctx, input }) {
return await ctx.prisma.uRL.update({
where: { id: input.id },
data: {
redirects: input.redirects,
},
});
},
});
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
celeroncoder
celeroncoderOP3y ago
here's the schema
model URL {
id String @id @default(cuid())
longURL String
code String @unique
shortURL String
redirects Int @default(0)
user User @relation(fields: [userId], references: [id])
userId String
}
model URL {
id String @id @default(cuid())
longURL String
code String @unique
shortURL String
redirects Int @default(0)
user User @relation(fields: [userId], references: [id])
userId String
}
and the uRL isn't a typo
Want results from more Discord servers?
Add your server