-
Learning about the basics of Prisma 2. The slightly confusing thing about Prisma 2 is that is many things, itโs worth understanding that it is totally different product to Prisma 1. Not drilled into the difference between the two product but some useful information here.
-
What I understand about Prisma 2 so far.
- It currently supports PostgreSQL, My SQL and SQL Lite. MongoDB support coming soon.
- DB schemas are defined using a
schema.prsisma
file which uses graphql-like syntax. - In here the db source is defined with
datasource
- The rest of the db schemas can also be defined in their own
model
blocks. There are lots of additional attributes/directives/modifers that can be used, so that you have more control over the feild types and creating relationships with other tables. - Once schemas are defined you need to run
prisma migrate
which will create real db schemas based on what was provided in theprisma.schema
file. It will handle db migrations too. - When working with Prisma in node, you will be using the
@prisma/client
. Under the hood , the client knows to read theprisma.schema
and generate a client that is tailored to your models. - The prisma client can thought of as a query model builder.