Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 801 Bytes

orm.md

File metadata and controls

47 lines (32 loc) · 801 Bytes

ORM (Object-Relational Mapping)

programming technique that allows developers to interact with a database using an object-oriented paradigm

  • examples:
    • prisma (recommended)
      • typescript
      • supports postgresql, mysql, mongodb, sqlite
      • simpler
    • TypeORM
      • typescript
    • sequelize
      • javascript
      • supports postgresql, mysql, sqlite, mongodb

prisma

  1. install prisma
npm install @prisma/client @prisma/cli --save-dev
  1. initialize prisma
npx prisma init
  • this command creates a .env file and a prisma/schema.prisma file
  1. define database schema

modify prisma/schema.prisma with your entities

  1. run migrations
npx prisma migrate dev --name init
  1. sync prisma with the database
npx prisma generate