Skip to content

akagaeng/prisma-v1-example

Repository files navigation

prisma-v1-example

Setup

brew tap prisma/prisma
brew install prisma

Set up and connect Prisma with a database

docker-compose up -d
  • Prisma running on http://localhost:4466
  • Prisma is connected to a local MySQL database (mysql://)
  • Currently unprotected
    • Set the managementApiSecret property to be protected securely

Configure Prisma API

prisma init --endpoint http://localhost:4466
# Create 2 files
  • prisma.yml: Prisma service definition
  • datamodel.prisma: GraphQL SDL-based datamodel (foundation for database)

Deploy the Prisma datamodel

prisma deploy
# model -> ddl

View and edit data from Prisma Admin

Generate the Prisma client

prisma generate
# generate files under specified in prisma.yml (./generated/prisma-client)

Setup sample Nodejs application

//  index.js
// yarn add prisma-client-lib

node index.js

[
  {
    id: 'cksg78f2j00120839i1gnxjvf',
    name: 'Alice',
    email: 'alice@Wonderland.com'
  }
]

Trouble Shooting

  • Apple M1 issues => try from other architecture environment
  • Database synchronize is not working properly
# try delete first, and deploy
prisma delete
prisma deploy

Documents