https://github.com/nithink-142/prisma-init
Prisma usage demo.
https://github.com/nithink-142/prisma-init
prisma sqlite typescript
Last synced: about 2 months ago
JSON representation
Prisma usage demo.
- Host: GitHub
- URL: https://github.com/nithink-142/prisma-init
- Owner: nithinK-142
- Created: 2023-11-14T16:56:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-15T08:20:33.000Z (over 2 years ago)
- Last Synced: 2024-12-29T15:17:56.329Z (over 1 year ago)
- Topics: prisma, sqlite, typescript
- Language: TypeScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Prisma init
A simple demo of CRUD operations using Prisma and SQLite.
### Prerequisites:
1. **Database:** You need to have a database installed. The example uses SQLite also Postgres, MongoDB, etc can be used.
2. **tsc (TypeScript Compiler):** Ensure that TypeScript and ts-node are installed globally or as project dependencies.
### Dependencies:
- **typescript:** The primary package for working with TypeScript.
- **ts-node:** TypeScript execution and REPL for Node.js.
- **@types/node:** TypeScript definition files for Node.js.
- **prisma:** The Prisma ORM (Object-Relational Mapping) library.
### Project Setup:
1. **Initialize npm:**
```sh
npm init -y
```
2. **Install Dependencies:**
```sh
npm install typescript ts-node @types/node -D
```
3. **Initialize TypeScript Configuration:**
```sh
npx tsc --init
```
4. **Install Prisma:**
```sh
npm install prisma
```
### Prisma Initialization:
- **Generate Prisma Configuration:**
```sh
npx prisma --datasource-provider sqlite
```
sqlite - database provider
### Database Migration:
- **Run Migrations after defining Models in schema.prisma:**
```sh
npx prisma migrate dev --name init
```
init - name of migration
### Run TypeScript Code:
- **Run index.ts:**
```sh
npx ts-node index.ts
```
PS - comment other functions while using the one you want.
### Prisma Studio (GUI):
- **Open Prisma Studio:**
```sh
npx prisma studio
```