### Example Project Setup with npm Source: https://www.prisma.io/docs/prisma-orm/quickstart/sql-server This snippet shows how to set up a project using npm, including installing dependencies and generating Prisma Client. It's a common setup for Node.js projects. ```bash npm dlx prisma init --datasource-provider mssql npm prisma generate ``` -------------------------------- ### Example Project Setup with yarn Source: https://www.prisma.io/docs/prisma-orm/quickstart/sql-server This snippet demonstrates setting up a project using yarn, including installing dependencies and generating Prisma Client. It's an alternative to npm for managing Node.js packages. ```bash yarn dlx prisma init --datasource-provider mssql yarn prisma generate ``` -------------------------------- ### Download Example and Install Dependencies Source: https://www.prisma.io/docs/orm/v6/prisma-client/deployment/traditional/deploy-to-heroku Navigate to your desired directory, create a new folder for the application, and download the example code. Then, install the necessary dependencies. ```bash mkdir my-app && cd my-app git clone https://github.com/prisma/prisma-examples.git . npm install ``` -------------------------------- ### Download Example and Install Dependencies Source: https://www.prisma.io/docs/llms-full.txt Download the example code and install project dependencies using your preferred package manager. ```bash mkdir prisma-on-koyeb cd prisma-on-koyeb curl https://github.com/koyeb/example-prisma/tarball/main/latest | tar xz --strip=1 ``` ```bash bun install ``` ```bash pnpm install ``` ```bash yarn install ``` ```bash npm install ``` -------------------------------- ### Install Dependencies and Start Dev Server (pnpm) Source: https://www.prisma.io/docs/llms-full.txt Navigate into the project directory, install dependencies, and start the development server using pnpm. ```bash cd my-solid-prisma-app pnpm install pnpm run dev ``` -------------------------------- ### Navigate and Install Dependencies Source: https://www.prisma.io/docs/guides/frameworks/solid-start Change directory to the project, install dependencies, and start the development server. ```bash cd my-solid-prisma-app bun install bun run dev ``` -------------------------------- ### Install Dependencies and Start Dev Server (yarn) Source: https://www.prisma.io/docs/llms-full.txt Navigate into the project directory, install dependencies, and start the development server using yarn. ```bash cd my-solid-prisma-app yarn install yarn dev ``` -------------------------------- ### Download Example and Install Dependencies Source: https://www.prisma.io/docs/llms-full.txt Download the Prisma Heroku example and install project dependencies using your preferred package manager. ```bash mkdir prisma-heroku cd prisma-heroku curl https://codeload.github.com/prisma/prisma-examples/tar.gz/latest | tar -xz --strip=3 prisma-examples-latest/deployment-platforms/heroku ``` ```bash ls -1 Procfile README.md package.json prisma public src ``` -------------------------------- ### Application Startup Output Example Source: https://www.prisma.io/docs/llms-full.txt Example output after starting the application, showing successful database insertion and retrieval. ```bash Inserting a new user into the database... Saved a new user with id: 1 Loading users from the database... Loaded users: [ User { id: 1, firstName: 'Timber', lastName: 'Saw', age: 25 } ] ``` -------------------------------- ### Install Dependencies Source: https://www.prisma.io/docs/orm/prisma-client/deployment/traditional/deploy-to-heroku Download the example project and install its dependencies using npm or yarn. ```bash git clone git@github.com:prisma/prisma-examples.git cd prisma-examples/deployment/heroku npm install # or yarn install ``` -------------------------------- ### Download Example and Install Dependencies Source: https://www.prisma.io/docs/llms-full.txt Downloads the example Prisma application code from GitHub and installs its Node.js dependencies. ```bash mkdir prisma-on-koyeb cd prisma-on-koyeb curl https://github.com/koyeb/example-prisma/tarball/main/latest | tar xz --strip=1 ``` ```bash npm install ``` -------------------------------- ### Install Prisma and Generate Client Source: https://www.prisma.io/docs/guides/runtimes/bun Install Prisma CLI and generate the Prisma Client for Bun. This is a one-time setup. ```bash bun install prisma --save-dev bunx prisma generate ``` -------------------------------- ### Install TypeORM Quickstart Dependencies Source: https://www.prisma.io/docs/prisma-postgres/quickstart/typeorm Installs the necessary packages for the TypeORM quickstart, including dotenv for environment variables. ```bash npm install @prisma/client typeorm dotenv ``` -------------------------------- ### Install and use Prisma with different package managers Source: https://www.prisma.io/docs/prisma-orm/add-to-existing-project/cockroachdb Examples of installing and using Prisma with Bun, pnpm, yarn, and npm. ```bash bunx prisma db pull ``` ```bash pnpm dlx prisma db pull ``` ```bash yarn dlx prisma db pull ``` ```bash npm run prisma db pull ``` -------------------------------- ### Install Dependencies and Download Example Source: https://www.prisma.io/docs/orm/prisma-client/deployment/traditional/deploy-to-heroku Navigate to your desired directory, create a new folder for the application, and download the example code. This sets up the project structure and necessary files. ```bash mkdir my-app && cd my-app git clone git@github.com:prisma/prisma-examples.git . cd prisma-examples/deployment/traditional/heroku npm install ``` -------------------------------- ### Prisma Client Initialization with OpenTelemetry (SDK Node) Source: https://www.prisma.io/docs/orm/v6/prisma-client/observability-and-logging/opentelemetry-tracing Example of initializing Prisma Client with OpenTelemetry tracing using the @opentelemetry/sdk-node package. This offers a simpler configuration aligned with OpenTelemetry's JavaScript getting started guide. ```typescript import { PrismaClient } from '@prisma/client' import { NodeSDK } from '@opentelemetry/sdk-node' // Configure OpenTelemetry NodeSDK const sdk = new NodeSDK() sdk.start() const prisma = new PrismaClient() async function main() { // Your Prisma operations here const users = await prisma.user.findMany() console.log(users) } main() .catch((e) => { throw e }) .finally(async () => { await prisma.$disconnect() }) ``` -------------------------------- ### Install Prisma and Dependencies Source: https://www.prisma.io/docs/prisma-orm/add-to-existing-project/cockroachdb Install Prisma CLI, Prisma Client, and necessary database drivers and adapters. Ensure you have Node.js and npm/yarn/pnpm/bun installed. ```bash npm install prisma --save-dev npm install @prisma/client pg @types/pg dotenv npm install @prisma/adapter-pg --save-dev ``` -------------------------------- ### Initialize a new Prisma project with an example model Source: https://www.prisma.io/docs/cli/init This command initializes a new Prisma project and generates an example model to help you get started quickly. Choose your preferred package manager. ```bash bunx --bun prisma init --with-model ``` ```bash pnpm prisma init --with-model ``` ```bash yarn prisma init --with-model ``` ```bash npm prisma init --with-model ``` -------------------------------- ### Install Dependencies Source: https://www.prisma.io/docs/prisma-postgres/quickstart/typeorm Navigate to the project directory and install the necessary project dependencies. ```bash cd typeorm-quickstart bun install ``` -------------------------------- ### Monorepo Prisma Client Setup Source: https://www.prisma.io/docs/orm/more/troubleshooting/nextjs When using Prisma ORM in a monorepo, ensure the Prisma Client is correctly installed and accessible. This example shows a common setup for managing Prisma within a monorepo structure. ```bash npm install -D prisma npx prisma generate ``` -------------------------------- ### Integration Test Script Example Source: https://www.prisma.io/docs/orm/prisma-client/testing/integration-testing This script automates the setup and execution of integration tests. It starts a Docker container, applies database migrations, and then runs your tests. ```bash yarn docker:up && yarn prisma migrate deploy && yarn test:integration ``` -------------------------------- ### Run Prisma Studio with different package managers Source: https://www.prisma.io/docs/guides/integrations/embed-studio Examples of how to start Prisma Studio using pnpm, yarn, and npm. Ensure you have the necessary dependencies installed for your chosen package manager. ```bash pnpm prisma studio ``` ```bash yarn prisma dev ``` ```bash npm run dev ``` -------------------------------- ### Create Project Directory and Download Example Source: https://www.prisma.io/docs/orm/prisma-client/deployment/traditional/deploy-to-koyeb These commands set up a new directory for your Prisma project on Koyeb and download the example application code. This is the initial step for deploying the Prisma application. ```bash mkdir prisma-on-koyeb cd prisma-on-koyeb curl https://github.com/koyeb/example-prisma/tarball/main/latest ``` -------------------------------- ### Get Me Endpoint - C# Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using C#'s HttpClient. This demonstrates making an authenticated GET request. ```csharp using System; using System.Net.Http; using System.Threading.Tasks; public class GetMe { public static async Task Main() { using var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://api.prisma.cloud/v1/users/me"), }; request.Headers.Add("Authorization", $"Bearer {Environment.GetEnvironmentVariable("PRISMA_API_TOKEN")}"); var response = await client.SendAsync(request); var responseBody = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } ``` -------------------------------- ### Prisma init command output example Source: https://www.prisma.io/docs/orm/v6/reference/prisma-cli-reference This example shows the typical output after running `prisma init`. It includes confirmation of setup and guidance on next steps. ```bash ✓ Select an authentication method Google Authenticating to Prisma Platform via ``` -------------------------------- ### Get Me Endpoint - Python Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using Python's 'requests' library. This demonstrates making an authenticated GET request. ```python import os import requests response = requests.get("https://api.prisma.cloud/v1/users/me", headers={"Authorization": f"Bearer {os.environ.get('PRISMA_API_TOKEN')}"}) data = response.json() print(data) ``` -------------------------------- ### Install and Run Prisma Studio with npm Source: https://www.prisma.io/docs/studio/getting-started Install Prisma Studio globally using npm and then run it. This command installs the tool and makes it available in your terminal. ```bash npm install --save-dev prisma npx prisma studio ``` -------------------------------- ### Download Prisma Heroku Example and Install Dependencies Source: https://www.prisma.io/docs/llms-full.txt This snippet downloads the Prisma Heroku example project and installs its Node.js dependencies. Ensure you have Node.js and npm installed. ```bash mkdir prisma-heroku cd prisma-heroku curl https://codeload.github.com/prisma/prisma-examples/tar.gz/latest | tar -xz --strip=3 prisma-examples-latest/deployment-platforms/heroku ``` ```bash npm install ``` -------------------------------- ### Install Prisma Client and PlanetScale Adapter with npm Source: https://www.prisma.io/docs/prisma-orm/add-to-existing-project/planetscale Use this command to install the Prisma client and the PlanetScale adapter for npm. It also installs Node.js types. ```bash npm install prisma @types/node dotenv npm install @prisma/client @prisma/adapter-planetscale undici ``` -------------------------------- ### Install Prisma and Dependencies Source: https://www.prisma.io/docs/prisma-postgres/quickstart/prisma-orm Install Prisma CLI and necessary types for Node.js and PostgreSQL adapter. Use --save-dev to install them as development dependencies. ```bash npm install prisma @types/node @prisma/client @prisma/adapter-pg dotenv --save-dev ``` -------------------------------- ### Get Me Endpoint - Go Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using Go. This shows how to set up an HTTP client and make a GET request with an authorization header. ```go package main import ( "encoding/json" "fmt" "net/http" "os" ) func main() { client := &http.Client{} req, err := http.NewRequest("GET", "https://api.prisma.cloud/v1/users/me", nil) if err != nil { panic(err) } req.Header.Add("Authorization", "Bearer "+os.Getenv("PRISMA_API_TOKEN")) resp, err := client.Do(req) if err != nil { panic(err) } defer resp.Body.Close() var data map[string]interface{} if err := json.NewDecoder(resp.Body).Decode(&data); err != nil { panic(err) } fmt.Println(data) } ``` -------------------------------- ### Create a new project with host and port Source: https://www.prisma.io/docs/management-api/endpoints/projects/post-projects This example shows how to create a new project by specifying the host and port for the database connection, in addition to the provider and database name. ```bash curl -X POST \n https://api.prisma.cloud/v1/projects \n -H \"Content-Type: application/json\" \n -d '{\n \"name\": \"my-new-project\",\n \"database\": {\n \"provider\": \"postgres\",\n \"host\": \"localhost\",\n \"port\": 5432,\n \"user\": \"user\",\n \"password\": \"password\",\n \"database\": \"database\"\n }\n}' ``` -------------------------------- ### Initialize Project and Install Prisma ORM Source: https://www.prisma.io/docs/guides/upgrade-prisma-orm/v1 Initialize a new project and add Prisma ORM and Prisma Client using Bun. Then, initialize Prisma in your project. ```bash bun init bun add prisma @prisma/client bunx --bun prisma init ``` -------------------------------- ### Get Me Endpoint - cURL Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using cURL. This is useful for quick testing and scripting. ```bash curl \ "https://api.prisma.cloud/v1/users/me" \ --header "Authorization: Bearer YOUR_API_TOKEN" ``` -------------------------------- ### Create Project with Host and Port Source: https://www.prisma.io/docs/management-api/endpoints/projects/post-projects This example demonstrates creating a project by specifying the host and port for the database connection. This is an alternative to providing a full connection string. ```bash curl -X POST \n https://api.prisma.cloud/v1/projects \n -H \"Content-Type: application/json\" \n -d '{\"name\": \"my-project\", \"host\": \"localhost\", \"port\": 5432}' ``` -------------------------------- ### Download Example and Install Dependencies Source: https://www.prisma.io/docs/orm/v6/prisma-client/deployment/traditional/deploy-to-koyeb Commands to create a project directory, navigate into it, and download the example Prisma application code from GitHub. ```bash mkdir prisma-on-koyeb cd prisma-on-koyeb curl https://github.com/koyeb/example-prisma/tarball/main/latest | tar xz --strip=1 ``` -------------------------------- ### Start Development Server Source: https://www.prisma.io/docs/ai/tutorials/linktree-clone Run your development server to see changes live. Use your preferred package manager. ```bash bun run dev ``` ```bash pnpm run dev ``` ```bash yarn dev ``` ```bash npm run dev ``` -------------------------------- ### Run Development Server with Different Package Managers Source: https://www.prisma.io/docs/guides/integrations/ai-sdk Examples for starting the development server using pnpm, yarn, or npm. Choose the command that matches your project's package manager. ```bash pnpm dev ``` ```bash yarn dev ``` ```bash npm run dev ``` -------------------------------- ### Get Me Endpoint - Java Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using Java's HttpClient. This shows how to construct an HTTP request with an authorization header. ```java import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class GetMe { public static void main(String[] args) throws IOException, InterruptedException { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.prisma.cloud/v1/users/me")) .header("Authorization", "Bearer " + System.getenv("PRISMA_API_TOKEN")) .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` -------------------------------- ### Download Example Code Source: https://www.prisma.io/docs/orm/prisma-client/deployment/traditional/deploy-to-flyio Use this command to download the example code from GitHub and navigate into the project directory. ```bash curl https://codeload.github.com/prisma/prisma-examples/tar.gz/latest | tar -xz --strip=2 prisma-examples-latest/deployment-platforms/render cd render ``` -------------------------------- ### Get Me Endpoint - JavaScript Example Source: https://www.prisma.io/docs/management-api/endpoints/misc/get-me Example of how to call the 'get me' endpoint using JavaScript with the fetch API. This demonstrates making authenticated API calls in a Node.js or browser environment. ```javascript const response = await fetch("https://api.prisma.cloud/v1/users/me", { headers: { Authorization: `Bearer ${process.env.PRISMA_API_TOKEN}`, }, }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Navigate to Project Directory Source: https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-cloudflare Change into the newly created project directory to begin installing dependencies. ```bash cd prisma-cloudflare-worker-example ``` -------------------------------- ### Install and Start ngrok Source: https://www.prisma.io/docs/llms-full.txt Install ngrok globally and start a tunnel to forward HTTP traffic from a specified port. This is used to expose your local development server to the internet for webhook testing. ```bash npm install --global ngrok ngrok http 4321 ``` -------------------------------- ### Add an example model Source: https://www.prisma.io/docs/cli/init Initializes a project and includes an example 'User' model in the generated schema file. ```bash bunx --bun prisma init --with-model ```