Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Latest commit

History

History
42 lines (31 loc) 路 1.49 KB

constructor-TYPESCRIPT-rsc5.mdx

File metadata and controls

42 lines (31 loc) 路 1.49 KB

import Collapse from "components/Markdown/Collapse" import Code from "components/Markdown/Code" import Warning from "components/Markdown/Warning"

export const meta = { title: 'Constructor (TypeScript)', position: 30, technology: 'typescript', technologyOrder: 2, articleGroup: 'Constructor', }

Overview

The Prisma constructor is used to create new instances of the Prisma client.

constructor(options: BaseClientOptions)

BaseClientOptions has the following properties (all are optional):

  • endpoint: string: The endpoint of your Prisma service. If not provided, the client will default to the endpoint that was specified in prisma.yml when the client was generated.
  • secret: string: The secret protecting the API of your Prisma service. If not provided, the client will default to the secret that was specified in prisma.yml when the client was generated.
  • debug: boolean: If set to true, each invokation of a method on the Prisma client will print the GraphQL query that is sent to the Prisma API to the console. Default: false.

Examples

Use default values for endpoint and secret that were specified in prisma.yml when the client was generated:

const prisma = new Prisma({})

Override default values for endpoint and secret that had been specified in prisma.yml when the client was generated:

const prisma = new Prisma({ 
  endpoint: "http://localhost:4466/hello-world/dev",
  secret: "mysecret42",
})