Contents Modern database access with Prisma Client 2.0 What’s in this release? Renaming the prisma2 (repository to prisma)
Renaming the prisma2 CLI
)
I currently use Prisma 1, what should I do? Try out Prisma 2.0 and share your feedback
TLDR
- The Prisma 2.0
Beta is ready. With the new website and documentation, it’s now the default for new developers getting started with Prisma.
- Prisma 2.0 mainly consists of Prisma Client, an auto-generated and type-safe query builder for Node.js and TypeScript. Prisma Migrate is considered experimental The
prisma / prisma2 repo was renamed to prisma / prisma (and the former Prisma 1 repo prisma / prisma repo is now called prisma / prisma1 . Try the new Prisma Client in 5 minutes by following the Quickstart
in the new docs .
Modern database access with Prisma Client 2.0
The new version of Prisma Client is a modern database access libary for Node.js and TypeScript. It can be used as an alternative to traditional ORMs and SQL query builders to read and write data in your database.
To setup, you need a (Prisma schema file and must add Prisma Client as a dependency to your project: npm install @prisma / client Prisma Client can be used in any Node.js or TypeScript backend application (including serverless applications and microservices). This can be a REST API , a (GraphQL API
a gRPC API or anything else that needs a database.
- I currently use Prisma 1, what should I do? Try out Prisma 2.0 and share your feedback
- The Prisma 2.0
Beta is ready. With the new website and documentation, it’s now the default for new developers getting started with Prisma.
- Prisma 2.0 mainly consists of Prisma Client, an auto-generated and type-safe query builder for Node.js and TypeScript. Prisma Migrate is considered experimental The
prisma / prisma2 repo was renamed to
prisma / prisma (and the former Prisma 1 repo prisma / prisma repo is now called
prisma / prisma1
. Try the new Prisma Client in 5 minutes by following the Quickstart
in the new docs .
- The new version of Prisma Client is a modern database access libary for Node.js and TypeScript. It can be used as an alternative to traditional ORMs and SQL query builders to read and write data in your database.
- To setup, you need a (Prisma schema file and must add Prisma Client as a dependency to your project: npm install @prisma / client
Prisma Client can be used in any Node.js or TypeScript backend application (including serverless applications and microservices). This can be a REST API , a (GraphQL API
a gRPC API or anything else that needs a database. - Prisma 2.0 mainly consists of Prisma Client, an auto-generated and type-safe query builder for Node.js and TypeScript. Prisma Migrate is considered experimental The
- TLDR
An abstraction that make the right thing easy (“pit of success”) Queries not classes to avoid complex model objects (Less boilerplate) so developers can focus on the important parts of their app Learn more about how Prisma makes developers productive in the (Introduction or get a taste of the Prisma Client API by checking out the code examples on the (website) .
The @ prisma / client
module is different from “conventional” node modules. With conventional node modules (eg lodash
), the entire package is downloaded into your node_modules (directory and only gets updated when you re-install the package. (The @ prisma / client node module is different. It is a "facade package" (basically a stub that does not contain any functional code. While you do need to install it (once
with npm install @ prisma / client , it is likely that the code inside the node_modules / @ prisma / client directory changes more often as you're evolving your application. That's because whenever you make changes to the Prisma schema, you need to re-generate Prisma Client which updates the code in the @ prisma / client (node module.)
because the (node_modules / @ prisma / client directory contains some code that is (tailored to your project, it is sometimes called a "smart node module":
node module is different. It is a "facade package" (basically a stub that does not contain any functional code. While you do need to install it (once
with npm install @ prisma / client , it is likely that the code inside the node_modules / @ prisma / client directory changes more often as you're evolving your application. That's because whenever you make changes to the Prisma schema, you need to re-generate Prisma Client which updates the code in the @ prisma / client (node module.)
because the (node_modules / @ prisma / client directory contains some code that is (tailored to your project, it is sometimes called a "smart node module":
Thanks to Prisma Client’s generated types which are included in the (index.d.ts) of the @ prisma / client module, this feature is available not only to TypeScript developers, but also when developing an application in plain JavaScript.
Type-safety for partial database queries A major benefit of Prisma Client compared to other ORMs and database tools is that it provides full type safety - even for "partial" database queris (ie when you query only the subset of a model's field or include a (relation ). As an example, consider this Prisma Client query (you can swith the tab to view the corresponding (Prisma models) ): (const) usersWithPartialPosts =(await) prisma
.user . findMany{{ include : {{ posts
: {{ select : {{ title : (true) ,published : (true) } } } } )(Note that the resulting
usersWithPartialPosts
will be statically typed to:
(export)
type User={{ id
: (number) email : (string) name : (string) |
} const usersWithPartialPosts : (User& ({ posts
: {{ title : (string) ;published : (boolean) ;} [] ; } )
The best way to get started with Prisma Client is by following the (Quickstart) (in the docs:) Quickstart (5 min)[
]Alternatively you can:
Setup a new project with Prisma from scratch
(Add Prisma to an existing project What's in this release?
- The Prisma 2.0 Beta comes with the following tools:
-
Prisma Migrate ( experimental : Declarative schema migration tool Prisma Studio ( experimental : GUI to view and edit data in your database Try the new Prisma Client in 5 minutes by following the Quickstart in the new docs. Note : Learn more about the Beta release in the (release notes .
Prisma Client : Auto-generated, type-safe query builder for Node.js & TypeScript
Because Prisma 2.0 is now the default for developers getting started with Prisma, the Prisma repositories have been renamed as follows:
- The
- The prisma / prisma
prisma / prisma2 repository has been renamed to prisma / prisma
repository has been renamed to
(prisma / prisma1)
During the Preview period, the CLI for Prisma 2.0 was invoked using the prisma2 command. With Prisma 2.0 being the default for new developers getting started with Prisma, the command is changed to just prisma . The exising prisma command of Prisma 1 is renamed to prisma1 . Also note that the installation of the npm packages changes: (Prisma version) Old CLI command N ew CLI command Old npm package name
(New npm package name
(2.0) prisma2 () prisma (prisma2) () @ prisma / cli
1.X prisma
() prisma1 prisma () prisma1
GIPHY App Key not set. Please check settings