{"id":13406575,"url":"https://github.com/prisma/prisma","last_synced_at":"2025-09-09T19:53:48.458Z","repository":{"id":37272620,"uuid":"192925833","full_name":"prisma/prisma","owner":"prisma","description":"Next-generation ORM for Node.js \u0026 TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB","archived":false,"fork":false,"pushed_at":"2025-05-05T10:47:51.000Z","size":137547,"stargazers_count":42138,"open_issues_count":2264,"forks_count":1735,"subscribers_count":237,"default_branch":"main","last_synced_at":"2025-05-05T11:06:32.871Z","etag":null,"topics":["cockroachdb","database","javascript","mariadb","mongo","mongodb","mongodb-orm","mssql","mysql","nodejs","orm","postgres","postgresql","prisma","prisma-client","query-builder","sql-server","sqlite","sqlserver","typescript"],"latest_commit_sha":null,"homepage":"https://www.prisma.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-20T13:33:47.000Z","updated_at":"2025-05-05T10:39:39.000Z","dependencies_parsed_at":"2024-04-22T13:45:02.021Z","dependency_job_id":"ba05b67e-1828-4c9c-b1fa-e001380ef45d","html_url":"https://github.com/prisma/prisma","commit_stats":{"total_commits":10136,"total_committers":277,"mean_commits":36.59205776173285,"dds":0.808405682715075,"last_synced_commit":"1eb333d55da0133679a4f63de47aba6bda823496"},"previous_names":["prisma/prisma2"],"tags_count":212,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fprisma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/prisma/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252486926,"owners_count":21755835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cockroachdb","database","javascript","mariadb","mongo","mongodb","mongodb-orm","mssql","mysql","nodejs","orm","postgres","postgresql","prisma","prisma-client","query-builder","sql-server","sqlite","sqlserver","typescript"],"created_at":"2024-07-30T19:02:33.940Z","updated_at":"2025-09-09T19:53:48.446Z","avatar_url":"https://github.com/prisma.png","language":"TypeScript","readme":"![Prisma](https://i.imgur.com/h6UIYTu.png)\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ePrisma\u003c/h1\u003e\n  \u003ca href=\"https://www.npmjs.com/package/prisma\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/prisma.svg?style=flat\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/prisma/prisma/blob/main/CONTRIBUTING.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/prisma/prisma/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-Apache%202-blue\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://pris.ly/discord\"\u003e\u003cimg alt=\"Discord\" src=\"https://img.shields.io/discord/937751382725886062?label=Discord\"\u003e\u003c/a\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://www.prisma.io/docs/getting-started/quickstart\"\u003eQuickstart\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://www.prisma.io/\"\u003eWebsite\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://www.prisma.io/docs/\"\u003eDocs\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://github.com/prisma/prisma-examples/\"\u003eExamples\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://www.prisma.io/blog\"\u003eBlog\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://pris.ly/discord?utm_source=github\u0026utm_medium=prisma\u0026utm_content=repo_readme\"\u003eDiscord\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://pris.ly/x?utm_source=github\u0026utm_medium=prisma\u0026utm_content=repo_readme\"\u003eTwitter\u003c/a\u003e\n  \u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n  \u003ca href=\"https://pris.ly/youtube?utm_source=github\u0026utm_medium=prisma\u0026utm_content=repo_readme\"\u003eYoutube\u003c/a\u003e\n  \u003cbr /\u003e\n  \u003chr /\u003e\n\u003c/div\u003e\n\n## What is Prisma?\n\nPrisma ORM is a **next-generation ORM** that consists of these tools:\n\n- [**Prisma Client**](https://www.prisma.io/docs/concepts/components/prisma-client): Auto-generated and type-safe query builder for Node.js \u0026 TypeScript\n- [**Prisma Migrate**](https://www.prisma.io/docs/concepts/components/prisma-migrate): Declarative data modeling \u0026 migration system\n- [**Prisma Studio**](https://github.com/prisma/studio): GUI to view and edit data in your database\n\nPrisma Client can be used in _any_ Node.js or TypeScript backend application (including serverless applications and microservices). This can be a [REST API](https://www.prisma.io/docs/concepts/overview/prisma-in-your-stack/rest), a [GraphQL API](https://www.prisma.io/docs/concepts/overview/prisma-in-your-stack/graphql), a gRPC API, or anything else that needs a database.\n\n**If you need a database to use with Prisma ORM, check out [Prisma Postgres](https://www.prisma.io/docs/getting-started/quickstart-prismaPostgres?utm_source=github\u0026utm_medium=prisma-readme) or if you are looking for our MCP Server, head [here](https://github.com/prisma/mcp).**\n\n## Getting started\n\n### Quickstart (5min)\n\nThe fastest way to get started with Prisma is by following the quickstart guides. You can choose either of two databases:\n\n- [Prisma Postgres](https://www.prisma.io/docs/getting-started/quickstart-prismaPostgres)\n- [SQLite](https://www.prisma.io/docs/getting-started/quickstart-sqlite)\n\n### Bring your own database\n\nIf you already have your own database, you can follow these guides:\n\n- [Add Prisma to an existing project](https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases-typescript-postgresql)\n- [Set up a new project with Prisma from scratch](https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases-typescript-postgresql)\n\n## How Prisma ORM works\n\nThis section provides a high-level overview of how Prisma ORM works and its most important technical components. For a more thorough introduction, visit the [Prisma documentation](https://www.prisma.io/docs/).\n\n### The Prisma schema\n\nEvery project that uses a tool from the Prisma toolkit starts with a [Prisma schema file](https://www.prisma.io/docs/concepts/components/prisma-schema). The Prisma schema allows developers to define their _application models_ in an intuitive data modeling language. It also contains the connection to a database and defines a _generator_:\n\n```prisma\n// Data source\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n\n// Generator\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\n// Data model\nmodel Post {\n  id        Int     @id @default(autoincrement())\n  title     String\n  content   String?\n  published Boolean @default(false)\n  author    User?   @relation(fields:  [authorId], references: [id])\n  authorId  Int?\n}\n\nmodel User {\n  id    Int     @id @default(autoincrement())\n  email String  @unique\n  name  String?\n  posts Post[]\n}\n```\n\nIn this schema, you configure three things:\n\n- **Data source**: Specifies your database connection (via an environment variable)\n- **Generator**: Indicates that you want to generate Prisma Client\n- **Data model**: Defines your application models\n\n---\n\n### The Prisma data model\n\nOn this page, the focus is on the data model. You can learn more about [Data sources](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-sources) and [Generators](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/generators) on the respective docs pages.\n\n#### Functions of Prisma models\n\nThe data model is a collection of [models](https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-models). A model has two major functions:\n\n- Represent a table in the underlying database\n- Provide the foundation for the queries in the Prisma Client API\n\n#### Getting a data model\n\nThere are two major workflows for \"getting\" a data model into your Prisma schema:\n\n- Generate the data model from [introspecting](https://www.prisma.io/docs/concepts/components/introspection) a database\n- Manually writing the data model and mapping it to the database with [Prisma Migrate](https://www.prisma.io/docs/concepts/components/prisma-migrate)\n\nOnce the data model is defined, you can [generate Prisma Client](https://www.prisma.io/docs/concepts/components/prisma-client/generating-prisma-client) which will expose CRUD and more queries for the defined models. If you're using TypeScript, you'll get full type-safety for all queries (even when only retrieving the subsets of a model's fields).\n\n---\n\n### Accessing your database with Prisma Client\n\n#### Generating Prisma Client\n\nThe first step when using Prisma Client is installing its npm package:\n\n```\nnpm install @prisma/client\n```\n\nNote that the installation of this package invokes the `prisma generate` command which reads your Prisma schema and _generates_ the Prisma Client code. The code will be located in `node_modules/.prisma/client`, which is exported by `node_modules/@prisma/client/index.d.ts`.\n\nAfter you change your data model, you'll need to manually re-generate Prisma Client to ensure the code inside `node_modules/.prisma/client` gets updated:\n\n```\nnpx prisma generate\n```\n\nRefer to the documentation for more information about [\"generating the Prisma client\"](https://www.prisma.io/docs/concepts/components/prisma-client/generating-prisma-client).\n\n#### Using Prisma Client to send queries to your database\n\nOnce the Prisma Client is generated, you can import it in your code and send queries to your database. This is what the setup code looks like.\n\n##### Import and instantiate Prisma Client\n\nYou can import and instantiate Prisma Client as follows:\n\n```ts\nimport { PrismaClient } from '@prisma/client'\n\nconst prisma = new PrismaClient()\n```\n\nor\n\n```js\nconst { PrismaClient } = require('@prisma/client')\n\nconst prisma = new PrismaClient()\n```\n\nNow you can start sending queries via the generated Prisma Client API, here are a few sample queries. Note that all Prisma Client queries return _plain old JavaScript objects_.\n\nLearn more about the available operations in the [Prisma Client docs](https://www.prisma.io/docs/concepts/components/prisma-client) or watch this [demo video](https://www.youtube.com/watch?v=LggrE5kJ75I\u0026list=PLn2e1F9Rfr6k9PnR_figWOcSHgc_erDr5\u0026index=4) (2 min).\n\n##### Retrieve all `User` records from the database\n\n```ts\nconst allUsers = await prisma.user.findMany()\n```\n\n##### Include the `posts` relation on each returned `User` object\n\n```ts\nconst allUsers = await prisma.user.findMany({\n  include: { posts: true },\n})\n```\n\n##### Filter all `Post` records that contain `\"prisma\"`\n\n```ts\nconst filteredPosts = await prisma.post.findMany({\n  where: {\n    OR: [{ title: { contains: 'prisma' } }, { content: { contains: 'prisma' } }],\n  },\n})\n```\n\n##### Create a new `User` and a new `Post` record in the same query\n\n```ts\nconst user = await prisma.user.create({\n  data: {\n    name: 'Alice',\n    email: 'alice@prisma.io',\n    posts: {\n      create: { title: 'Join us for Prisma Day 2021' },\n    },\n  },\n})\n```\n\n##### Update an existing `Post` record\n\n```ts\nconst post = await prisma.post.update({\n  where: { id: 42 },\n  data: { published: true },\n})\n```\n\n#### Usage with TypeScript\n\nNote that when using TypeScript, the result of this query will be _statically typed_ so that you can't accidentally access a property that doesn't exist (and any typos are caught at compile-time). Learn more about leveraging Prisma Client's generated types on the [Advanced usage of generated types](https://www.prisma.io/docs/concepts/components/prisma-client/advanced-usage-of-generated-types) page in the docs.\n\n## Community\n\nPrisma has a large and supportive [community](https://www.prisma.io/community) of enthusiastic application developers. You can join us on [Discord](https://pris.ly/discord) and here on [GitHub](https://github.com/prisma/prisma/discussions).\n\n## Badges\n\n[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io) [![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io)\n\nBuilt something awesome with Prisma? 🌟 Show it off with these [badges](https://github.com/prisma/presskit?tab=readme-ov-file#badges), perfect for your readme or website.\n\n```\n[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io)\n```\n\n```\n[![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io)\n```\n\n## Security\n\nIf you have a security issue to report, please contact us at [security@prisma.io](mailto:security@prisma.io?subject=[GitHub]%20Prisma%202%20Security%20Report%20).\n\n## Support\n\n### Ask a question about Prisma\n\nYou can ask questions and initiate [discussions](https://github.com/prisma/prisma/discussions/) about Prisma-related topics in the `prisma` repository on GitHub.\n\n👉 [**Ask a question**](https://github.com/prisma/prisma/discussions/new)\n\n### Create a bug report for Prisma\n\nIf you see an error message or run into an issue, please make sure to create a bug report! You can find [best practices for creating bug reports](https://www.prisma.io/docs/guides/other/troubleshooting-orm/creating-bug-reports) (like including additional debugging output) in the docs.\n\n👉 [**Create bug report**](https://pris.ly/prisma-prisma-bug-report)\n\n### Submit a feature request\n\nIf Prisma currently doesn't have a certain feature, be sure to check out the [roadmap](https://www.prisma.io/docs/more/roadmap) to see if this is already planned for the future.\n\nIf the feature on the roadmap is linked to a GitHub issue, please make sure to leave a 👍 reaction on the issue and ideally a comment with your thoughts about the feature!\n\n👉 [**Submit feature request**](https://github.com/prisma/prisma/issues/new?assignees=\u0026labels=\u0026template=feature_request.md\u0026title=)\n\n## Contributing\n\nRefer to our [contribution guidelines](https://github.com/prisma/prisma/blob/main/CONTRIBUTING.md) and [Code of Conduct for contributors](https://github.com/prisma/prisma/blob/main/CODE_OF_CONDUCT.md).\n\n## Tests Status\n\n- Prisma Tests Status:\n  [![Prisma Tests Status](https://github.com/prisma/prisma/workflows/CI/badge.svg)](https://github.com/prisma/prisma/actions/workflows/test.yml?query=branch%3Amain)\n- Ecosystem Tests Status:\n  [![Ecosystem Tests Status](https://github.com/prisma/ecosystem-tests/workflows/test/badge.svg)](https://github.com/prisma/ecosystem-tests/actions/workflows/test.yaml?query=branch%3Adev)\n","funding_links":[],"categories":["TypeScript","Packages","Tools","Database Tools","API","Projects using `@faker-js/faker`","Database \u0026 Messaging MCP Servers","Repository","包","ORMs \u0026 Query Builders","Uncategorized","Node.js 相关","其他__大数据","Recently Updated","node","Scala","Awesome Tools","Databases","typescript","目录","Cloud Services","database","Built with TypeScript","ORM","Node.js","服务器实现","🌟 Community Integrations","Integrated","Database","Databases \u0026 ORM","Other"],"sub_categories":["Database","Julia Libraries","数据库","JavaScript / TypeScript","Uncategorized","网络服务_其他","[Feb 17, 2025](/content/2025/02/17/README.md)","ORM","Languages","How to Submit","Tools - Miscellaneous","Crystal Libraries","Libraries","Other","Node.js","数据与知识","Database \u0026 CMS"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fprisma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fprisma/lists"}