Hey guys. I'd like to do a "ping" or "connection c...
# orm-help
f
Hey guys. I'd like to do a "ping" or "connection check" when my express-server starts to check if prisma is available via the generated client. Any ideas on how to do this best? (I mean, i could just fire a random query or sth, but maybe there is a recommended way)
d
A highly selective query like getting the first user is probably the best. (similar as you would do it in SQL DBs,
SELECT 1
)
p
Maybe try doing a GET request to http://localhost:4466/management and validate with a 200 response.
a
Nice thing about getting something from the db is that you will also know that db connection is working
I'm not sure if /management will give 200 ok if db connection is broken?
p
You are right, didn't think about that. Maybe ping the db port OR doing a query would be the next option.
I am using cloudwatch that notifies me when the prisma docker container throw error regarding the db connection failure.
f
Thanks, guys! Probably will do a very simple query