Today, we are excited to share the `3.4.0` stable release 🎉
🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20prisma%20release%20v3.4.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/3.4.0) about the release.** 🌟
Major improvements & new features
Support for PostgreSQL 14
We are pleased to announce that Prisma version `3.4.0` provides support for PostgreSQL 14. For a full list of our supported databases and their versions, see our [documentation](https://www.prisma.io/docs/reference/database-reference/supported-databases).
MongoDB
Support for Order By Aggregate Group
In Prisma version `3.4.0`, we add support on MongoDB databases for using `orderBy` with aggregate groups. This was previously available for relational databases.
For example, if the data about your application's users includes their city of residence, you can determine which cities have the largest user groups. The following query sorts each `city` group by the number of users in that group, and returns the results in descending order (largest group first):
ts
const groupBy = await prisma.user.groupBy({
by: ['city'],
_count: {
city: true,
},
orderBy: {
_count: {
city: 'desc',
},
},
})
For more information refer to our [documentation about ordering by groups](https://www.prisma.io/docs/concepts/components/prisma-client/aggregation-grouping-summarizing#order-by-aggregate-group).
Initial support for MongoDB in `prisma db push`
The `prisma db push` command is used to sync your Prisma schema and your database schema in development.
Because MongoDB has a unique approach to database schema management, this initial release only syncs `unique`, `unique` and `index` annotations in your schema.
Let's look at a quick example using this Prisma schema:
prisma
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator js {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model BlogPost {
id String id default(dbgenerated()) map("_id") db.ObjectId
title String unique
}
After running `prisma db push` the CLI will display which changes were made:
Applying the following changes:
[+] Unique index `BlogPost_title_key` on ({"title":1})
Let's keep iterating on the schema. We apply the following changes:
- remove the unique index from `title`
- add a compound unique index on the combination of `author` and `title`
- add an index to `title`
prisma
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator js {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model BlogPost {
id String id map("_id") db.ObjectId
author String
title String
unique([author, title], map: "titleAuthorShouldBeUniqueUnique")
index([title])
}
and run `prisma db push` again, we see what changes were applied:
Applying the following changes:
[-] Unique index `BlogPost_title_key`
[+] Index `BlogPost_title_idx` on ({"title":1})
[+] Unique index `titleAuthorShouldBeUniqueUnique` on ({"author":1,"title":1})
And voilà, the index and unique definitions in our schema are reflected in the database.
There is a known limitation with _empty collections_: if you `db push` indexes or uniques on fields that do not have values in the collection (they are missing in all existing documents), and you use `db pull` after that, the indexes and uniques will not be pulled because the fields will not be in your schema.
Since this is a Preview feature, any feedback is very much appreciated. Please get in touch by opening a [GitHub issue](https://github.com/prisma/prisma/issues/new).
Introspection of embedded documents in MongoDB
For those interested in helping us getting introspection of embedded documents right, we packaged a first iteration into the CLI. More info in the Github [issue](https://github.com/prisma/prisma/issues/10016).
Prisma Client Go
Data Proxy Support
Connection limit issues got you down? By using Prisma's Data Proxy, you can pool your connections to avoid overloading your database.
With this release, Prisma Client Go can now read and write to the [Data Proxy](https://www.prisma.io/docs/concepts/components/prisma-data-platform#prisma-data-proxy).
You can generate a "Data Proxy"-enabled Go Client with the following command:
bash
PRISMA_CLIENT_ENGINE_TYPE='dataproxy' go run github.com/prisma/prisma-client-go generate
Then you can use the Go Client as you normally would:
go
amas, err := client.Ama.FindMany().Exec(ctx)
if err != nil {
return err
}
for _, ama := range amas {
fmt.Println(ama.Status, ":", ama.Question)
}
// ANSWERED : How did you build this AMA page?
// ANSWERED : What is zero-cost type safety?
// UNANSWERED : What developer tools do you like?
Please note that the Data Proxy is currently in Early Access and still under active development. We do not recommend using the Data Proxy for production loads. If you run into any issues while trying to use the Go Client with the Data Proxy, please leave us a note in [this issue](https://github.com/prisma/prisma-client-go/issues/663).
JSON Filtering Support
We've had JSON filtering support in the TypeScript Client since . In 3.4.0, we're bringing support to the Go Client. Let's take a look at an example.
Given the following Prisma schema:
prisma
generator client {
provider = "prisma-client-go"
previewFeatures = ["filterJson"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Log {
id Int id default(autoincrement())
level Level
message String
meta Json
}
enum Level {
INFO
WARN
ERROR
}
You can now write the following to query a specific service name inside inside the `meta` field:
go
logs, _ := client.Log.FindMany(
db.Log.Meta.Path([]string{"service"}),
db.Log.Meta.Equals(db.JSON("\"api\"")),
).Exec(ctx)
See some more examples of what you can do in [our documentation](https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields). Note that the examples are written in Typescript, but the same concepts apply to Go as well!
Fixes and improvements
Prisma Client
- [Add test for custom engine location from the Prisma Client JS instance](https://github.com/prisma/prisma/issues/6171)
- [Importing prisma/client takes 6s (includes repro and which line causes it)](https://github.com/prisma/prisma/issues/8178)
- [CFW: Find cause and fix error 500](https://github.com/prisma/prisma/issues/9594)
- [PCO: Discuss high-level goals](https://github.com/prisma/prisma/issues/9602)
- [MongoDB: `orderByAggregateGroup` (since 2.21.0)](https://github.com/prisma/prisma/issues/9160)
Prisma Migrate
- [Test CLI database creation for all supported databases](https://github.com/prisma/prisma/issues/8615)
- [Add postgres 14 to databases tested in CI](https://github.com/prisma/prisma/issues/9545)
- [Validation: duplicate field name checks do not check if the field name is mapped](https://github.com/prisma/prisma/issues/9770)
- [Validate composite type cycles](https://github.com/prisma/prisma/issues/9782)
- [dbgenerated values are not created when pushing model](https://github.com/prisma/prisma/issues/9828)
- [Implement introspection of composite types on mongodb](https://github.com/prisma/prisma/issues/9864)
- [Implement reformatting for composite types](https://github.com/prisma/prisma/issues/10054)
Language tools (e.g. VS Code)
- [Send Slack message on failing CI tests](https://github.com/prisma/language-tools/issues/761)
- [Language tool support for named contraints/indexes](https://github.com/prisma/language-tools/issues/825)
The Prisma Serverless Data Conference is happening on November 18!
Make sure to claim your ticket for our free [Prisma Serverless Data Conference](https://www.prisma.io/serverless) about all things databases and serverless with fantastic speakers from companies like PlanetScale, MongoDB, Vercel, Netlify, Cloudflare and CockroachDB.
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another ["What's new in Prisma"](https://www.youtube.com/watch?v=xyJESipjfNQ&ab_channel=Prisma) livestream.
The stream takes place [on Youtube](https://www.youtube.com/watch?v=xyJESipjfNQ&ab_channel=Prisma) on **Thursday, November 04** at **5pm Berlin | 9am San Francisco**.