Prepared Statement doesn't exist
"message": "db error: ERROR: prepared statement \"s114\" does not exist\n\nCaused by:\n ERROR: prepared statement \"s114\" does not exist" "message": "db error: ERROR: prepared statement \"s114\" does not exist\n\nCaused by:\n ERROR: prepared statement \"s114\" does not exist"Hi, I am making like a voting thing with many to many relationship, and this one is causing me a problem.
schema.ts
export const hubVotes = pgTable(
"HubVotes",
{
userId: integer("UserId")
.notNull(),
hubPostId: integer("HubId")
.notNull(),
vote: voteEnum("Vote").notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.hubPostId),
})
);export const hubVotes = pgTable(
"HubVotes",
{
userId: integer("UserId")
.notNull(),
hubPostId: integer("HubId")
.notNull(),
vote: voteEnum("Vote").notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.hubPostId),
})
);api
route.patch("/", async (req, res) => {
const vote = req.body as NewHubVote;
console.log(req.userId, vote.hubPostId)
//* Check The Existing Vote
const existingvote = await searchHubVote(req.userId);
if (existingvote) {
//* If the vote are same, remove the votes
if (existingvote.vote === vote.vote) {
await removeHubVote({ userId: req.userId });
res.status(200)
return res.send("OK");
}
await updateHubVote({
userId: req.userId,
hubPostId: vote.hubPostId,
vote: vote.vote,
});
res.status(200)
return res.send("OK");
}
//* If no Vote Existed, Create a New One
await createHubVote({
userId: req.userId,
hubPostId: vote.hubPostId,
vote: vote.vote,
});
res.status(200)
return res.send("OK")
});
}route.patch("/", async (req, res) => {
const vote = req.body as NewHubVote;
console.log(req.userId, vote.hubPostId)
//* Check The Existing Vote
const existingvote = await searchHubVote(req.userId);
if (existingvote) {
//* If the vote are same, remove the votes
if (existingvote.vote === vote.vote) {
await removeHubVote({ userId: req.userId });
res.status(200)
return res.send("OK");
}
await updateHubVote({
userId: req.userId,
hubPostId: vote.hubPostId,
vote: vote.vote,
});
res.status(200)
return res.send("OK");
}
//* If no Vote Existed, Create a New One
await createHubVote({
userId: req.userId,
hubPostId: vote.hubPostId,
vote: vote.vote,
});
res.status(200)
return res.send("OK")
});
}I have check the payload which is also correct, and in correct type :3