Get started with Prisma - Step 0
Step 0 - Setup a simple Prisma Project
2022-05-14
Introduction
This is the first post of a series of mini (should take a few minutes) tutorials to get you started with Prisma. In this tutorial I set up the Prisma Client and print some attributes of a relation stored on a simple SQLite database (supplied). This tutorial has batteries included (.env.example and db/mydb.sqlite). You just need to have a recent node.js installed.
What's included?
First clone this repo: https://github.com/vtripolitakis/prisma-test
This small repo gets you started with an SQLite database and Prisma/Typescript. In order to advance things fast, an SQLite version of the Northwind database(supplied by MS Access back in the time) is supplied in the db/mydb.sqlite folder.
Instructions
- Run 
yarn install - Run 
yarn prisma init - Copy 
.env.exampleto.envto use the simple sqlite database ondbfolder - Edit 
prisma/schema.prismaand make sure the provider is"sqlite" 
datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}
- Use introspection to populate the 
prisma.schemaand issue:yarn prisma db pull - Run 
yarn prisma generateto generate the@prisma/clientfor this demo application 
What I can do next?
- Either run 
yarn tscand thennode dist/to see the Employees table on the console. - Or run 
yarn prisma studioto start Prisma Studio and check the supplied database. -- Play around and have fun with thesrc/index.ts - Wait the next tutorial on this series.
 
have fun!
Crafted with ❤ in Crete. © 2022-2024