Today, we are excited to share the `5.14.0` stable release 🎉
🌟 **Help us spread the word about Prisma by starring the repo ☝️ or [posting on X](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20prisma%20release%20v5.14.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/5.14.0) about the release.** 🌟
Highlights
Share your feedback about Prisma ORM
We want to know how you like working with Prisma ORM in your projects! Please [take our 2min survey](https://pris.ly/orm/survey/release-5-14) and let us know what you like or where we can improve 🙏
`createManyAndReturn()`
We’re happy to announce the availability of a new, top-level Prisma Client query: `createManyAndReturn()`. It works similarly to `createMany()` but uses a `RETURNING` clause in the SQL query to retrieve the records that were just created.
Here’s an example of creating multiple posts and then immediately returning those posts.
tsx
const postBodies = req.json()['posts']
const posts = prisma.post.createManyAndReturn({
data: postBodies
});
return posts
Additionally,`createManyAndReturn()` supports the same options as `findMany()`, such as the ability to return only specific fields.
tsx
const postBodies = req.json()['posts']
const postTitles = prisma.post.createManyAndReturn({
data: postBodies,
select: {
title: true,
},
});
return postTitles
Full documentation for this feature can be found [in the Prisma Client API Reference](https://www.prisma.io/docs/orm/reference/prisma-client-reference#createmanyandreturn).
**Note**: Because `createManyAndReturn()` uses the `RETURNING` clause, it is only supported by PostgreSQL, CockroachDB, and SQLite databases. At this time, `relationLoadStrategy: join` is not supported in `createManyAndReturn()` queries.
MongoDB performance improvements
Previously, Prisma ORM suffered from performance issues when using the `in` operator or when including related models in queries against a MongoDB database. These queries were translated by the Prisma query engine in such a way that indexes were skipped and collection scans were used, leading to slower queries especially on large datasets.
With 5.14.0, Prisma ORM now rewrites queries to use a combination of `$or` and `$eq` operators, leading to dramatic performance increases for queries that include `in` operators or relation loading.
Fixes and improvements
Prisma Client
- [`createMany()` should return the created records](https://github.com/prisma/prisma/issues/8131)
- [Generating Prisma client without any model in its schema](https://github.com/prisma/prisma/issues/11582)
- [MongoDB: Performance issue with nested `take` on many-to-one relationship](https://github.com/prisma/prisma/issues/13865)
- [Slow queries on MongoDB using `include` for relations](https://github.com/prisma/prisma/issues/15156)
- [[MongoDB] Performance issue in `findMany()` query execution with `in`](https://github.com/prisma/prisma/issues/15983)
- [MongoDB nested/`include` query slow](https://github.com/prisma/prisma/issues/17142)
- [MongoDB Connector generates queries which do not take advantage of indices.](https://github.com/prisma/prisma/issues/17396)
- [Mongodb Nested Queries Not Using Indexes](https://github.com/prisma/prisma/issues/18025)
- [MongoDB slow delete with `onDelete: SetNull`](https://github.com/prisma/prisma/issues/19169)
- [Slow query with many-to-one relationship on MongoDB](https://github.com/prisma/prisma/issues/20600)
- [`prisma init --with-model`](https://github.com/prisma/prisma/issues/20915)
- [Fixed version of `opentelemetry/*` dependencies](https://github.com/prisma/prisma/issues/21473)
- [Usage of deprecated punycode module](https://github.com/prisma/prisma/issues/21644)
- [Bug: D1 One-to-Many Relation INSERTs fail with `The required connected records were not found.` when using indices](https://github.com/prisma/prisma/issues/23902)
Prisma Migrate
- [Empty `dbgenerated()` still breaking for `Unsupported()` types](https://github.com/prisma/prisma/issues/15654)
- [Validation error when `shadowDatabaseUrl` is identical to `url` (or `directUrl`)](https://github.com/prisma/prisma/issues/16628)
- [MongoDB Query with 'in' condition will cause COLLSCAN, without leveraging indexes](https://github.com/prisma/prisma/issues/19955)
- ["Not Authorised" when directly applying Prisma generated migrations to Cloudflare D1 with `PRAGMA foreign_key_check;`](https://github.com/prisma/prisma/issues/23827)
Language tools (e.g. VS Code)
- [make superior: model generate](https://github.com/prisma/language-tools/issues/1651)
- [Missing code autocomplete for referential actions with mongodb](https://github.com/prisma/language-tools/issues/1676)
- [add codelens provider w/ generate client command](https://github.com/prisma/language-tools/pull/1710)
Company news
Prisma Changelog
Curious about all things Prisma? Be sure to check out the [Prisma Changelog](https://www.prisma.io/changelog) for updates across Prisma's products, including ORM, Accelerate, and Pulse!
New product announcement: Prisma Optimize
With this release, we are excited to introduce a new Prisma product. We’re calling it “Optimize” because that’s what it does! Let your favorite ORM also help you debug the performance of your application.
Check out our [announcement blog post](https://www.prisma.io/blog/prisma-optimize-early-access) for more details, including a demo video.
Credits
Huge thanks to pranayat, yubrot, skyzh, anuraaga, gutyerrez, avallete, ceddy4395, Kayoshi-dev for helping!