Check if id exists using node-postgres

WIth MongoDB & Mongoose, I could check if an id exists like so:
if (!mongoose.Types.ObjectId.isValid(id))
return res.status(404).send(`No post with id: ${id}`);
if (!mongoose.Types.ObjectId.isValid(id))
return res.status(404).send(`No post with id: ${id}`);
How can I do that using Postgres & Expressjs? I'm using node-postgres for the queries.
2 Replies
ErickO
ErickO3y ago
I think that only checks if the id passed is valid not if it exists
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server