DEV Community

Cover image for It's Prisma Time - Create Db
Luca Del Puppo for This is Learning

Posted on

5

It's Prisma Time - Create Db

Hi Guys πŸ‘‹
welcome back.
Finally, today it's time to create our database, so don't waste time, and get started.
How can you create your database?
It's simple! You have to run the following script:

npx prisma db push
Enter fullscreen mode Exit fullscreen mode

This script creates in your prisma folder a SQLite database called dev.db.
The database's name is taken from the variable DATABASE_URL in the .env file and inside of the file you can find the next table.
Post Table
Ok, now you have your database so it's time to get back at the challenge left open last article.
Run the script

yarn dev
Enter fullscreen mode Exit fullscreen mode
{ posts: [] }
Enter fullscreen mode Exit fullscreen mode

it's work
Ok, there aren't data but it works πŸ₯³
So now you have a database and you can search data inside it, at this point, it's time to create relations between our entities, but it's the goal of the next article πŸ€ͺ

That's all for today guys!
See you soon
Bye Bye πŸ‘‹

You can find the code relative to this post here

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (3)

Collapse
 
gersonec profile image
Gerson Enriquez β€’

It is possible to have a setup up with mongo db? I'm trying to setup with mongo but constantly getting an error.
Image description

Collapse
 
puppo profile image
Luca Del Puppo β€’

Hey @gersonec ,
Try to take a look at this repo. You can find a fastify app with prisma and mongodb.
Let me know if you resolve the problem.
Another check you can do is to check if you have the option ?authSource=admin in your connection string.

Collapse
 
gersonec profile image
Gerson Enriquez β€’

That option in the connection string solved my problem! Thanks a lot!

Postgres on Neon - Get the Free Plan

No credit card required. The database you love, on a serverless platform designed to help you build faster.

Get Postgres on Neon

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay