Skip to content

Instantly share code, notes, and snippets.

@kohei-takata
Last active June 13, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohei-takata/91a3ba26cf243b204dc2b29cd0cb30a4 to your computer and use it in GitHub Desktop.
Save kohei-takata/91a3ba26cf243b204dc2b29cd0cb30a4 to your computer and use it in GitHub Desktop.

exprasma

For prisma

Notes: Uses docker

  1. Install prisma npm install prisma

  2. Create service directory (The name will be passed by command line argument) mkdir hello-world cd hello-world

  3. Use templates of docker-compose TODO: Change to be able to use PostgreSQL or MongoDB.

cp ../docker-compose.yml .

  1. Launch docker-compose up -d

  2. Configure prisma API npx prisma init --endpoint http://localhost:4466

  3. Deploy prisma datamodel prisma deploy

  4. Generate prisma client

Append the following lines to the end of your prisma.yml

generate:
  - generator: javascript-client
    output: ./generated/prisma-client/
  1. Generate

prisma generate

9 Prepare Node Application

touch index.js npm init -y npm install --save prisma-client-lib

I think below is not appropriate

const { prisma } = require('./generated/prisma-client')

// A `main` function so that we can use async/await
async function main() {
  // Create a new user called `Alice`
  const newUser = await prisma.createUser({ name: 'Alice' })
  console.log(`Created new user: ${newUser.name} (ID: ${newUser.id})`)

  // Read all users from the database and print them to the console
  const allUsers = await prisma.users()
  console.log(allUsers)
}

main().catch(e => console.error(e))

For Expo

  1. Install expo

npm install expo-cli

  1. Init Expo (The name will be passed by command line argument)

npx expo init my-new-project cd my-new-project

  1. Copy template js files

cp ../index.js .

  1. Start Expo

npx expo start

@kohei-takata
Copy link
Author

@kohei-takata
Copy link
Author

Use TypeScript

@kohei-takata
Copy link
Author

kohei-takata commented Jun 11, 2019

Upload to Now or prisma cloud or AWS

@kohei-takata
Copy link
Author

kohei-takata commented Jun 12, 2019

Optional Include Node application to docker
k8s support?

@kohei-takata
Copy link
Author

Linux and Windows support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment