nikolasburk
@prisma/cli
to the prisma
npm package
Going forward, you can install the Prisma CLI via the prisma
npm package:
npm install prisma --save-dev
or
yarn add prisma --dev
The reason for this is that a number of users were experiencing issues when running the npx prisma
command. Without a local installation of the @prisma/cli
package, this would invoke the Prisma 1 CLI leading to an error message. From now on, npx prisma
is always going to work.
👨👩👧👦 Efficient bulk creates with createMany
Insert data a whole lot faster with createMany
. Here's an example:
const result = await prisma.user.createMany({
data: [
{ email: "<mailto:alice@prisma.io|alice@prisma.io>" },
{ email: "<mailto:mark@prisma.io|mark@prisma.io>" },
{ email: "<mailto:jackie@prisma.io|jackie@prisma.io>" },
{ email: "<mailto:bob@prisma.io|bob@prisma.io>" },
],
});
console.log(`Created ${result.count} users!`);
To enable this feature, add the createMany
feature flag to your Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["createMany"]
}
Learn more in this issue.
↕️ Order by relation fields with orderBy
Ever wish you could order posts by an author's name? Or sort transactions by account? Now you can! We've expanded orderBy
to support ordering by relations:
cons posts = await prisma.post.findMany({
orderBy: [
{
author: {
name: "asc",
},
},
],
});
To enable this feature, add the orderByRelations
feature flag to your Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByRelations"]
}
Learn more in this issue.
🦿 Improvements to the nativeTypes
Preview feature
We are working hard on making the Prisma experience smoother for folks that are using the nativeTypes
Preview feature and are getting close to releasing it for General Availability.
• New Unsupported(type: String)
type allows to surface any database type in the Prisma schema
• New notation for default values via dbgenerated(value: String)
• New native type attributes available on PostgreSQL
Be sure to check out the release notes for more information on these changes! If you have any feedback for this feature, please share it on GitHub.
🦦 Prisma Client Go gets dynamic filters
Give your users more control over how they filter and order their data. Build up filters over time instead of all at once.
Here's an example of setting specific attributes dynamically:
func CreateUser(w http.ResponseWriter, r *http.Request) {
var params []db.UserSetParam
email := r.PostFormValue("email")
kind := r.PostFormValue("kind")
if kind == "customer" {
// Set the referer for users of type customer only
params = append(params, db.User.Referer.Set(r.Header.Get("Referer"))
}
user, err := client.User.CreateOne(
db.User.Kind.Set(kind),
db.User.Email.Set(email),
params...,
).Exec(r.Context())
// ... Handle the response
}