Skip to content
Branch: master
Find file History
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
prisma adjust datamodel to v1.1 Apr 15, 2019
src prettier Jan 17, 2019
.babelrc fix script example Nov 28, 2018
.flowconfig adjust .flowconfigs Nov 29, 2018
README.md update to v1.34 May 28, 2019
package.json Update dependency flow-bin to v0.101.0 Jun 11, 2019

README.md

Simple Flow Script Example

This example shows how to use the Prisma client in a simple Flow script to read and write data in a database.

How to use

1. Download example & install dependencies

Clone the repository:

git clone git@github.com:prisma/prisma-examples.git

Install Node dependencies:

cd prisma-examples/flow/script
npm install

2. Install the Prisma CLI

To run the example, you need the Prisma CLI. Please install it via NPM or using another method:

npm install -g prisma

3. Set up database & deploy Prisma datamodel

For this example, you'll use a free demo database (AWS Aurora) hosted in Prisma Cloud. To set up your database, run:

prisma deploy

Then, follow these steps in the interactive CLI wizard:

  1. Select Demo server
  2. Authenticate with Prisma Cloud in your browser (if necessary)
  3. Back in your terminal, confirm all suggested values
Alternative: Run Prisma locally via Docker
  1. Ensure you have Docker installed on your machine. If not, you can get it from here.
  2. Create docker-compose.yml for MySQL (see here for Postgres):
    version: '3'
    services:
      prisma:
        image: prismagraphql/prisma:1.34
        restart: always
        ports:
        - "4466:4466"
        environment:
          PRISMA_CONFIG: |
            port: 4466
            databases:
              default:
                connector: mysql
                host: mysql
                port: 3306
                user: root
                password: prisma
                migrations: true
      mysql:
        image: mysql:5.7
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: prisma
        volumes:
          - mysql:/var/lib/mysql
    volumes:
      mysql:
  3. Run docker-compose up -d
  4. Set the endpoint in prisma.yml to http://localhost:4466
  5. Run prisma deploy

You can now use Prisma Admin to view and edit your data by appending /_admin to your Prisma endpoint.

4. Run the script

Execute the script with this command:

npm run start

Next steps

You can’t perform that action at this time.