PackageTrack

npm · #3659 most downloaded on npm

@prisma/client

7.10.0prisma/prisma

Prisma Client is an auto-generated, type-safe and modern JavaScript/TypeScript ORM for Node.js that's tailored to your data. Supports PostgreSQL, CockroachDB, MySQL, MariaDB, SQL Server, SQLite & MongoDB databases.

Release timeline

10653 releases since 2020
20202026

One column per quarter.

Releases

  1. 3.12.0-dev.2728 Mar 2022pre-release

    Nothing published for this version

  2. 3.12.0-dev.2624 Mar 2022pre-release

    Nothing published for this version

  3. 3.12.0-dev.2524 Mar 2022pre-release

    Nothing published for this version

  4. 3.12.0-dev.2424 Mar 2022pre-release

    Nothing published for this version

  5. 3.12.0-dev.2324 Mar 2022pre-release

    Nothing published for this version

  6. 3.12.0-dev.2224 Mar 2022pre-release

    Nothing published for this version

  7. 3.12.0-dev.2123 Mar 2022pre-release

    Nothing published for this version

  8. 3.12.0-dev.2023 Mar 2022pre-release

    Nothing published for this version

  9. 3.12.0-dev.1923 Mar 2022pre-release

    Nothing published for this version

  10. 3.12.0-dev.1823 Mar 2022pre-release

    Nothing published for this version

  11. 3.12.0-dev.1722 Mar 2022pre-release

    Nothing published for this version

  12. 3.12.0-dev.1622 Mar 2022pre-release

    Nothing published for this version

  13. 3.12.0-dev.1522 Mar 2022pre-release

    Nothing published for this version

  14. 3.12.0-dev.1421 Mar 2022pre-release

    Nothing published for this version

  15. 3.12.0-dev.1321 Mar 2022pre-release

    Nothing published for this version

  16. 3.12.0-dev.1221 Mar 2022pre-release

    Nothing published for this version

  17. 3.12.0-dev.1121 Mar 2022pre-release

    Nothing published for this version

  18. 3.12.0-dev.1021 Mar 2022pre-release

    Nothing published for this version

  19. 3.12.0-dev.918 Mar 2022pre-release

    Nothing published for this version

  20. 3.12.0-dev.818 Mar 2022pre-release

    Nothing published for this version

  21. 3.12.0-dev.716 Mar 2022pre-release

    Nothing published for this version

  22. 3.12.0-dev.616 Mar 2022pre-release

    Nothing published for this version

  23. 3.12.0-dev.516 Mar 2022pre-release

    Nothing published for this version

  24. 3.12.0-dev.416 Mar 2022pre-release

    Nothing published for this version

  25. 3.12.0-dev.316 Mar 2022pre-release

    Nothing published for this version

  26. 3.12.0-dev.216 Mar 2022pre-release

    Nothing published for this version

  27. 3.12.0-dev.116 Mar 2022pre-release

    Nothing published for this version

  28. 3.11.2-dev.124 Mar 2022pre-release

    Nothing published for this version

  29. 3.11.124 Mar 2022
    Release notes

    Today, we are issuing the 3.11.1 patch release.

    MongoDB (Preview)

    Breaking: Filters no longer return undefined fields by default

    In 3.11.1, we've changed what data is returned when filtering MongoDB documents on undefined fields. The new rule is that undefined fields are excluded by default unless explicitly filtered for. This allows you to query for undefined and null values separately.

    Let's take a look at a concrete example. Given the following Prisma schema:

    model Address {
        id     Int    @id @map("_id")
        city   String
        street String? // Note that street is optional
    }
    

    For Mongo, optional fields can either be null or undefined (absent). The following documents are all valid for the schema above:

    { "_id": 1, "city": "San Fransisco", "street": "Market st." }
    { "_id": 2, "city": "Seattle", "street": null }
    { "_id": 3, "city": "Chicago" }
    

    Prior to 3.11.1, if you queried for where: { street: null }, you'd get _id: 2 and _id: 3. In 3.11.1, you'll only get _id: 2. The ability to also query for the missing fields has also been added. For details, refer to the new isSet below to learn more.

    There are a few exceptions to this new default:

    • A having filter on an aggregated field will return undefined fields. This is because aggregation on undefined fields yields null, not undefined, thus matching the filter.
    • Filters on undefined to-many relations (e.g., the backing array of a many-to-many is undefined) will currently include those relations in the result set.

    New isSet filter operation

    To compensate for missing fields on documents no longer being returned by the filters above, we’ve added a new isSet: bool filter. This filter can be used to include fields that are undefined on documents.

    Using the example above, to include the undefined fields, you can use an OR:

    await prisma.address.findMany({
      where: {
        OR: [
          { street: { isSet: false } },
          { street: null }
        ]
      }
    })
    

    The isSet operation has been added to all scalar and embedded fields that are optional.

    New unset operation

    In 3.11.1, you can also remove a field with the unset operation.

    Using the example above, let's write a query to remove the street field:

    await prisma.address.update({
      where: {
        id: 10,
      },
      data: {
        street: {
          unset: true,
        },
      },
    })
    

    This effectively sets the street field to undefined in the database.

    New updateMany operation

    We now support updating embedded documents that match specific criteria.

    For example, given the following schema:

    model Product {
      id          Int  @id @map("_id")
      name        String  @unique
      photos      Photo[]
    }
    
    type Photo {
      height Int    @default(200)
      width  Int    @default(100)
      url    String
    }
    

    Let's update the photo with a url of 1.jpg to 2.png:

    const product = prisma.product.update({
      where: {
        id: 10,
      },
      data: {
        photos: {
          updateMany: {
            where: {
              url: '1.jpg',
            },
            data: {
              url: '2.png',
            },
          },
        },
      },
    })
    

    New deleteMany operation

    Similar to updateMany, you can also remove embeds that match specific criteria.

    Using the Prisma Schema above, let's delete all photos with a height of 100:

    const product = prisma.product.update({
      where: {
        id: 10,
      },
      data: {
        photos: {
          deleteMany: {
            where: {
              height: 100,
            },
          },
        },
      },
    })
    
    Open source →
  30. 3.11.1-dev.324 Mar 2022pre-release

    Nothing published for this version

  31. 3.11.1-dev.224 Mar 2022pre-release

    Nothing published for this version

  32. 3.11.1-dev.124 Mar 2022pre-release

    Nothing published for this version

  33. 3.11.015 Mar 2022
    Release notes

    Today, we are excited to share the 3.11.0 stable release 🎉

    🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

    Major improvements and new features

    Experimental support for Embedded Document Filters

    In the previous release, we added embedded document support for creates, updates, and deletes. In version 3.11.0, we’re adding the ability to filter embedded documents.

    Given the following schema:

    datasource db {
      provider = "mongodb"
      url      = env("DATABASE_URL")
    }
    
    generator client {
      provider        = "prisma-client-js"
      previewFeatures = ["mongoDb"]
    }
    
    model Product {
      id     String  @id @default(auto()) @map("_id") @db.ObjectId
      photos Photo[]
    }
    
    model Order {
      id              String   @id @default(auto()) @map("_id") @db.ObjectId
      shippingAddress Address
      billingAddress  Address?
    }
    
    type Photo {
      height Int
      width  Int
      url    String
    }
    
    type Address {
      street String
      city   String
      zip    String
    }
    

    You can now filter within an embedded document:

    // find all orders with the same shipping address
    const orders = await prisma.order.findMany({
      where: {
        shippingAddress: {
          equals: {
            street: "555 Candy Cane Lane",
            city: "Wonderland",
            zip: "52337",
          },  
        },
      },
    })
    

    You can also filter on a "contains many" relationship:

    // find all products that don't have photos
    const product = prisma.product.findMany({
      where: {
        photos: {
          isEmpty: true
        }
      },
    })
    

    This scratches the surface of what's possible. For a complete list of available operations, have a look at our documentation. Please share your feedback in this issue.

    Ordering by embedded documents is in Preview

    In addition to filtering, Prisma version 3.11.0 now supports sorting by an embedded document.

    Using the example schema above, you can sort orders by their zip code:

    // sort orders by zip code in ascending order
    const orders = await prisma.order.findMany({
      orderBy: {
        shippingAddress: {
          zip: "asc",
        },
      },
    })
    

    Learn more about this feature in our documentation and don’t hesitate to reach out in this issue.

    MongoDB query logging support

    In this release, we’ve added the ability to log MongoDB queries. You can enable query logging in the PrismaClient constructor:

    const prisma = new PrismaClient({
      log: [
        {
          emit: 'event',
          level: 'query',
        },
      ]
    })
    
    prisma.$on('query', (e) => console.log(e.query))
    

    After enabling query logging, you'll start to see logs that resemble this in your console:

    db.User.deleteMany({ _id: ( $in: [ “62261e0b18139c6099ba7097”, ], }, }) 
    db.User.deleteMany({ _id: ( $in: [ “6226277a96069500743edcf9”, ], }, })
    

    The logs output by Prisma have the same format as the mongosh console, so you can pipe the queries from your logs directly into your shell.

    MongoDB introspection update

    We've updated the type inference behavior for MongoDB on introspection.

    Prisma samples a field's data to select an appropriate type on introspection. In the past, Prisma picked the type used most often for fields with data with multiple types. However, this could cause problems when retrieving mixed data during runtime and throw exceptions, such as Prisma Studio or in Prisma Client queries.

    From 3.11.0, Prisma defaults to the Json type to all fields with mixed data types instead. Additionally, Prisma will still show a warning on the console and add a comment to the introspected Prisma schema so it is clear where such cases occur and that you can do something to fix them.

    Prisma Client logger revamp

    In 3.11.0, we’ve rewritten our internal logger to reduce lock contention and enable future features like tracing. This is the first of many upcoming changes to improve the Prisma Client’s throughput, so if you were running into an upper limit on query performance, it’s time to update Prisma Client and give it a try!

    If you're running into query performance issues, please open an issue or connect with us on Slack.

    CockroachDB now supports migrations (Preview)

    We're excited to announce Preview support for migrations for CockroachDB. You can now evolve your Prisma schema and propagate the changes to your database using Prisma Migrate.

    Give the feature a try and let us know what you think in this issue.

    Detecting state of a diff with migrate diff using exit code

    Prisma version 3.11.0 includes a new --exit-code flag to the migrate diff command to detect the state of a diff in several ways.

    You can use the flag as follows:

    npx prisma migrate diff --preview-feature \
    --exit-code \
    --from-[...] \
    --to-[...]
    

    Here's a list of the default and changed behavior of the error codes:

    ## Default behavior of exit codes
    0: Returned when the diff is empty or non-empty
    1: Returned on error
    
    ## Changed behavior when --exit-code is used
    0: Returned when the diff is empty
    1: Returned on error
    2: Returned when the diff is non-empty
    

    Read about it in the reference documentation.

    Fixes and improvements

    Prisma

    Prisma Client

    Prisma Migrate

    Language tools (e.g. VS Code)

    Prisma Engines

    Credits

    Huge thanks to @hayes, @maddhruv, @jasimon for helping!

    📺 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" livestream.

    The stream takes place on YouTube on Thursday, March 17 at 5 pm Berlin | 8 am San Francisco.

    Open source →
  34. 3.11.0-integration-mobc-fix.19 Mar 2022pre-release

    Nothing published for this version

  35. 3.11.0-integration-fix-empty-path.123 Feb 2022pre-release

    Nothing published for this version

  36. 3.11.0-integration-chore-composite-list-filters.315 Mar 2022pre-release

    Nothing published for this version

  37. 3.11.0-integration-chore-composite-list-filters.215 Mar 2022pre-release

    Nothing published for this version

  38. 3.11.0-integration-chore-composite-list-filters.115 Mar 2022pre-release

    Nothing published for this version

  39. 3.11.0-dev.6215 Mar 2022pre-release

    Nothing published for this version

  40. 3.11.0-dev.6115 Mar 2022pre-release

    Nothing published for this version

  41. 3.11.0-dev.6014 Mar 2022pre-release

    Nothing published for this version

  42. 3.11.0-dev.5914 Mar 2022pre-release

    Nothing published for this version

  43. 3.11.0-dev.5814 Mar 2022pre-release

    Nothing published for this version

  44. 3.11.0-dev.5714 Mar 2022pre-release

    Nothing published for this version

  45. 3.11.0-dev.5614 Mar 2022pre-release

    Nothing published for this version

  46. 3.11.0-dev.5514 Mar 2022pre-release

    Nothing published for this version

  47. 3.11.0-dev.5414 Mar 2022pre-release

    Nothing published for this version

  48. 3.11.0-dev.5314 Mar 2022pre-release

    Nothing published for this version

  49. 3.11.0-dev.5213 Mar 2022pre-release

    Nothing published for this version

  50. 3.11.0-dev.5112 Mar 2022pre-release

    Nothing published for this version

  51. 3.11.0-dev.5011 Mar 2022pre-release

    Nothing published for this version

  52. 3.11.0-dev.4911 Mar 2022pre-release

    Nothing published for this version

  53. 3.11.0-dev.4811 Mar 2022pre-release

    Nothing published for this version

  54. 3.11.0-dev.4711 Mar 2022pre-release

    Nothing published for this version

  55. 3.11.0-dev.4611 Mar 2022pre-release

    Nothing published for this version

  56. 3.11.0-dev.4510 Mar 2022pre-release

    Nothing published for this version

  57. 3.11.0-dev.4410 Mar 2022pre-release

    Nothing published for this version

  58. 3.11.0-dev.4310 Mar 2022pre-release

    Nothing published for this version

  59. 3.11.0-dev.4210 Mar 2022pre-release

    Nothing published for this version

  60. 3.11.0-dev.419 Mar 2022pre-release

    Nothing published for this version