Access to Express.js and Prisma console

Issue

So im building app based on Express and using Prisma ORM. What i need is to SSH to a server, open up express.js console and create new db entry using prisma. Something similar to python manage.py shell for Django or rails console for Rails. Is there a solution for this of any kind?

Solution

Like I pointed in the comment there is a way ( kind of ) to get access to a running express instance. If that’s all you need follow:

How can I open a console to interact with Express app?

Express doesn’t exactly have a feature like rails console which is a framework feature in that case.

That said, I question the long term implication of this approach. If you really just need to seed some data, write an "init" script, and call it after you ssh into a server or using some CI/CD approach. This is more re-usable, since you can even pass a json file to the script to load dynamic data.

Also, Prismajs has an official way to seed the data ( if that’s what you need) that you can leverage:

https://www.prisma.io/docs/guides/database/seed-database

UPDATE:

If you are able to run to code on your machine and point the remote database, then you can use node --inspect to debug in a chrome console. Which should give you about the same effect as a rails REPL

https://medium.com/@tbernardes/debugging-nodejs-with-chrome-inspector-devtools-1cd2ef323b5e

Answered By – Shaunak

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published